diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index f21c58ec6cd..2e27e41b97d 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,9 +4,14 @@ "name": "Mac", "includePath": [ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1", - "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include", + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.3/include", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", + "/opt/homebrew/include", + "/opt/homebrew/opt/openssl@3/include", + "/opt/homebrew/opt/openssl@1.1/include", + "/opt/homebrew/opt/openssl/include", "/usr/local/include", + "/usr/local/opt/openssl@3/include", "/usr/local/opt/openssl@1.1/include", "/usr/local/opt/openssl/include", "${workspaceFolder}", @@ -20,12 +25,11 @@ "${workspaceFolder}/iocore/net", "${workspaceFolder}/iocore/utils", "${workspaceFolder}/lib", - "${workspaceFolder}/lib/records", + "${workspaceFolder}/src/records", "${workspaceFolder}/lib/yamlcpp/include", + "${workspaceFolder}/lib/swoc/include", "${workspaceFolder}/mgmt", - "${workspaceFolder}/mgmt/api", - "${workspaceFolder}/mgmt/api/include", - "${workspaceFolder}/mgmt/utils", + "${workspaceFolder}/mgmt/rpc", "${workspaceFolder}/proxy", "${workspaceFolder}/proxy/hdrs", "${workspaceFolder}/proxy/http", diff --git a/doc/admin-guide/monitoring/statistics/core/bandwidth.en.rst b/doc/admin-guide/monitoring/statistics/core/bandwidth.en.rst index 73f99665b70..89e8a747ae6 100644 --- a/doc/admin-guide/monitoring/statistics/core/bandwidth.en.rst +++ b/doc/admin-guide/monitoring/statistics/core/bandwidth.en.rst @@ -38,39 +38,3 @@ Bandwidth and Transfer .. ts:stat:: global proxy.process.http.user_agent_response_header_total_size integer :type: counter :units: bytes - -.. ts:stat:: global proxy.process.http.user_agent_speed_bytes_per_sec_100 integer - :type: derivative - :units: bytes - :ungathered: - -.. ts:stat:: global proxy.process.http.user_agent_speed_bytes_per_sec_100K integer - :type: derivative - :units: bytes - :ungathered: - -.. ts:stat:: global proxy.process.http.user_agent_speed_bytes_per_sec_100M integer - :type: derivative - :units: bytes - :ungathered: - -.. ts:stat:: global proxy.process.http.user_agent_speed_bytes_per_sec_10K integer - :type: derivative - :units: bytes - :ungathered: - -.. ts:stat:: global proxy.process.http.user_agent_speed_bytes_per_sec_10M integer - :type: derivative - :units: bytes - :ungathered: - -.. ts:stat:: global proxy.process.http.user_agent_speed_bytes_per_sec_1K integer - :type: derivative - :units: bytes - :ungathered: - -.. ts:stat:: global proxy.process.http.user_agent_speed_bytes_per_sec_1M integer - :type: derivative - :units: bytes - :ungathered: - diff --git a/doc/admin-guide/monitoring/statistics/core/cache.en.rst b/doc/admin-guide/monitoring/statistics/core/cache.en.rst index 62ba1ee4471..bf846233954 100644 --- a/doc/admin-guide/monitoring/statistics/core/cache.en.rst +++ b/doc/admin-guide/monitoring/statistics/core/cache.en.rst @@ -76,8 +76,6 @@ Cache .. ts:stat:: global proxy.process.cache.hdr_marshals integer :ungathered: -.. ts:stat:: global proxy.process.cache.KB_read_per_sec float -.. ts:stat:: global proxy.process.cache.KB_write_per_sec float .. ts:stat:: global proxy.process.cache.lookup.active integer :ungathered: @@ -103,7 +101,6 @@ Cache :ungathered: .. ts:stat:: global proxy.process.cache.read.failure integer -.. ts:stat:: global proxy.process.cache.read_per_sec float .. ts:stat:: global proxy.process.cache.read.success integer .. ts:stat:: global proxy.process.cache.remove.active integer :ungathered: @@ -131,7 +128,6 @@ Cache .. ts:stat:: global proxy.process.cache.write.backlog.failure integer .. ts:stat:: global proxy.process.cache.write_bytes_stat integer .. ts:stat:: global proxy.process.cache.write.failure integer -.. ts:stat:: global proxy.process.cache.write_per_sec float .. ts:stat:: global proxy.process.cache.write.success integer .. ts:stat:: global proxy.process.cache.span.errors.read integer diff --git a/doc/admin-guide/monitoring/statistics/core/dns.en.rst b/doc/admin-guide/monitoring/statistics/core/dns.en.rst index fed97d05517..d2667b827b9 100644 --- a/doc/admin-guide/monitoring/statistics/core/dns.en.rst +++ b/doc/admin-guide/monitoring/statistics/core/dns.en.rst @@ -22,8 +22,7 @@ DNS *** -.. ts:stat:: global proxy.process.dns.fail_avg_time integer - :type: derivative +.. ts:stat:: global proxy.process.dns.fail_time integer :units: milliseconds :ungathered: @@ -47,8 +46,7 @@ DNS The number of resetting TCP connection in TCP_RETRY connection mode. -.. ts:stat:: global proxy.process.dns.lookup_avg_time integer - :type: derivative +.. ts:stat:: global proxy.process.dns.lookup_time integer :units: milliseconds :ungathered: @@ -79,8 +77,7 @@ DNS :type: counter :ungathered: -.. ts:stat:: global proxy.process.dns.success_avg_time integer - :type: derivative +.. ts:stat:: global proxy.process.dns.success_time integer :units: milliseconds :ungathered: @@ -92,4 +89,3 @@ DNS The total number of DNS lookups which have been performed since statistics collection began. - diff --git a/doc/admin-guide/monitoring/statistics/core/http-document-size.en.rst b/doc/admin-guide/monitoring/statistics/core/http-document-size.en.rst index 46d5c145d54..a872dd19428 100644 --- a/doc/admin-guide/monitoring/statistics/core/http-document-size.en.rst +++ b/doc/admin-guide/monitoring/statistics/core/http-document-size.en.rst @@ -26,54 +26,3 @@ HTTP Document Size :type: counter :units: bytes :ungathered: - -.. ts:stat:: global proxy.process.http.request_document_size_100 integer - :type: counter - :ungathered: - -.. ts:stat:: global proxy.process.http.request_document_size_10K integer - :type: counter - :ungathered: - -.. ts:stat:: global proxy.process.http.request_document_size_1K integer - :type: counter - :ungathered: - -.. ts:stat:: global proxy.process.http.request_document_size_1M integer - :type: counter - :ungathered: - -.. ts:stat:: global proxy.process.http.request_document_size_3K integer - :type: counter - :ungathered: - -.. ts:stat:: global proxy.process.http.request_document_size_5K integer - :type: counter - :ungathered: - -.. ts:stat:: global proxy.process.http.request_document_size_inf integer - :type: counter - :ungathered: - -.. ts:stat:: global proxy.process.http.response_document_size_100 integer - :type: counter - -.. ts:stat:: global proxy.process.http.response_document_size_10K integer - :type: counter - -.. ts:stat:: global proxy.process.http.response_document_size_1K integer - :type: counter - -.. ts:stat:: global proxy.process.http.response_document_size_1M integer - :type: counter - -.. ts:stat:: global proxy.process.http.response_document_size_3K integer - :type: counter - -.. ts:stat:: global proxy.process.http.response_document_size_5K integer - :type: counter - -.. ts:stat:: global proxy.process.http.response_document_size_inf integer - :type: counter - :ungathered: - diff --git a/doc/admin-guide/monitoring/statistics/core/http-transaction.en.rst b/doc/admin-guide/monitoring/statistics/core/http-transaction.en.rst index 9dd730c2be4..09b3dbd9114 100644 --- a/doc/admin-guide/monitoring/statistics/core/http-transaction.en.rst +++ b/doc/admin-guide/monitoring/statistics/core/http-transaction.en.rst @@ -23,12 +23,6 @@ HTTP Transaction **************** -.. ts:stat:: global proxy.process.http.avg_transactions_per_client_connection float - :type: derivative - -.. ts:stat:: global proxy.process.http.avg_transactions_per_server_connection float - :type: derivative - .. ts:stat:: global proxy.process.http.total_transactions_time integer :type: counter :units: seconds diff --git a/doc/admin-guide/monitoring/statistics/core/origin.en.rst b/doc/admin-guide/monitoring/statistics/core/origin.en.rst index b58ff3d5a25..99aa5bfb3ab 100644 --- a/doc/admin-guide/monitoring/statistics/core/origin.en.rst +++ b/doc/admin-guide/monitoring/statistics/core/origin.en.rst @@ -50,34 +50,6 @@ Origin Server :type: counter :units: bytes -.. ts:stat:: global proxy.process.http.origin_server_speed_bytes_per_sec_100 integer - :type: derivative - :units: bytes - -.. ts:stat:: global proxy.process.http.origin_server_speed_bytes_per_sec_100K integer - :type: derivative - :units: bytes - -.. ts:stat:: global proxy.process.http.origin_server_speed_bytes_per_sec_100M integer - :type: derivative - :units: bytes - -.. ts:stat:: global proxy.process.http.origin_server_speed_bytes_per_sec_10K integer - :type: derivative - :units: bytes - -.. ts:stat:: global proxy.process.http.origin_server_speed_bytes_per_sec_10M integer - :type: derivative - :units: bytes - -.. ts:stat:: global proxy.process.http.origin_server_speed_bytes_per_sec_1K integer - :type: derivative - :units: bytes - -.. ts:stat:: global proxy.process.http.origin_server_speed_bytes_per_sec_1M integer - :type: derivative - :units: bytes - .. ts:stat:: global proxy.process.http.origin_shutdown.pool_lock_contention integer :type counter :units bytes @@ -137,4 +109,3 @@ Origin Server .. ts:stat:: global proxy.process.http.origin_shutdown.tunnel_abort integer :type counter :units bytes - diff --git a/doc/appendices/command-line/traffic_top.en.rst b/doc/appendices/command-line/traffic_top.en.rst index 02ede4bcd7b..c7d5d27c9c3 100644 --- a/doc/appendices/command-line/traffic_top.en.rst +++ b/doc/appendices/command-line/traffic_top.en.rst @@ -487,24 +487,6 @@ Statistics: |TS| also provides statistics for every other response code. The keen observer will have hopefully already recognized the pattern in statistic names. -100 B, 1 KB, 3 KB, 5 KB, 10 KB, 1 MB, > 1 MB -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Each of these fields indicates the percentage of responses from |TS| which fell -within a particular size (document body size, excluding response headers). The -individual fields are the upper bounds of exclusive *buckets*, meaning that a -response with a document body of 4,500 bytes will be counted in the ``5 KB`` -field, but not in any of the smaller sizes. - -Statistics: -:ts:stat:`proxy.process.http.response_document_size_100`, -:ts:stat:`proxy.process.http.response_document_size_1K`, -:ts:stat:`proxy.process.http.response_document_size_3K`, -:ts:stat:`proxy.process.http.response_document_size_5K`, -:ts:stat:`proxy.process.http.response_document_size_10K`, -:ts:stat:`proxy.process.http.response_document_size_1M`, -:ts:stat:`proxy.process.http.response_document_size_inf`. - Client ------ diff --git a/doc/developer-guide/cache-architecture/data-structures.en.rst b/doc/developer-guide/cache-architecture/data-structures.en.rst index 6c54b329455..3e2d55f59d8 100644 --- a/doc/developer-guide/cache-architecture/data-structures.en.rst +++ b/doc/developer-guide/cache-architecture/data-structures.en.rst @@ -419,10 +419,6 @@ Data Structures .. member:: LINK link - .. member:: RecRawStatBlock vol_rsb - - per volume stat - .. class:: ConfigVol This class represents an individual volume. diff --git a/include/api/Metrics.h b/include/api/Metrics.h index c191e3acc9a..97ee8dca599 100644 --- a/include/api/Metrics.h +++ b/include/api/Metrics.h @@ -40,19 +40,21 @@ namespace ts class Metrics { private: - using self_type = Metrics; - using IdType = int32_t; // Could be a tuple, but one way or another, they have to be combined to an int32_t. - using AtomicType = std::atomic; + using self_type = Metrics; public: + using IntType = std::atomic; + using IdType = int32_t; // Could be a tuple, but one way or another, they have to be combined to an int32_t. + static constexpr uint16_t METRICS_MAX_BLOBS = 8192; static constexpr uint16_t METRICS_MAX_SIZE = 2048; // For a total of 16M metrics static constexpr IdType NOT_FOUND = std::numeric_limits::min(); // <16-bit,16-bit> = + static const auto MEMORY_ORDER = std::memory_order_relaxed; private: using NameAndId = std::tuple; using NameContainer = std::array; - using AtomicContainer = std::array; + using AtomicContainer = std::array; using MetricStorage = std::tuple; using MetricBlobs = std::array; using LookupTable = std::unordered_map; @@ -84,9 +86,16 @@ class Metrics // the std::atomic as the underlying class for a single metric, and be happy. IdType newMetric(const std::string_view name); IdType lookup(const std::string_view name) const; - AtomicType *lookup(IdType id, std::string_view *name = nullptr) const; + IntType *lookup(IdType id, std::string_view *name = nullptr) const; - AtomicType & + // 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)); + } + + IntType & operator[](IdType id) { return *lookup(id); @@ -103,7 +112,7 @@ class Metrics { auto metric = lookup(id); - return (metric ? metric->fetch_add(val) : NOT_FOUND); + return (metric ? metric->fetch_add(val, MEMORY_ORDER) : NOT_FOUND); } // ToDo: Do we even need these inc/dec functions? @@ -112,7 +121,7 @@ class Metrics { auto metric = lookup(id); - return (metric ? metric->fetch_sub(val) : NOT_FOUND); + return (metric ? metric->fetch_sub(val, MEMORY_ORDER) : NOT_FOUND); } std::string_view name(IdType id) const; @@ -125,6 +134,35 @@ class Metrics return (id >= 0 && ((blob < _cur_blob && entry < METRICS_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: @@ -237,6 +275,7 @@ class Metrics MetricBlobs _blobs; uint16_t _cur_blob = 0; uint16_t _cur_off = 0; + }; // class Metrics } // namespace ts diff --git a/include/records/P_RecProcess.h b/include/records/P_RecProcess.h index 5d58c47e4ef..48efd184cf8 100644 --- a/include/records/P_RecProcess.h +++ b/include/records/P_RecProcess.h @@ -32,8 +32,13 @@ #include "I_RecProcess.h" #include "P_RecDefs.h" +#include + //------------------------------------------------------------------------- // Protected Interface //------------------------------------------------------------------------- int RecExecRawStatSyncCbs(); + +using RecCallbackFunction = std::function; +void RecRegNewSyncStatSync(RecCallbackFunction callback); diff --git a/iocore/aio/AIO.cc b/iocore/aio/AIO.cc index 9cd6446d940..889002715d8 100644 --- a/iocore/aio/AIO.cc +++ b/iocore/aio/AIO.cc @@ -62,69 +62,8 @@ int thread_is_created = 0; RecInt cache_config_threads_per_disk = 12; RecInt api_config_threads_per_disk = 12; -RecRawStatBlock *aio_rsb = nullptr; +AIOStatsBlock aio_rsb; Continuation *aio_err_callback = nullptr; -// AIO Stats -std::atomic aio_num_read = 0; -std::atomic aio_bytes_read = 0; -std::atomic aio_num_write = 0; -std::atomic aio_bytes_written = 0; - -/* - * Stats - */ - -static int -aio_stats_cb(const char * /* name ATS_UNUSED */, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id) -{ - (void)data_type; - (void)rsb; - int64_t new_val = 0; - int64_t diff = 0; - int64_t count, sum; - ink_hrtime now = ink_get_hrtime(); - // The RecGetGlobalXXX stat functions are cheaper than the - // RecGetXXX functions. The Global ones are expensive - // for increments and decrements. But for AIO stats we - // only do Sets and Gets, so they are cheaper in our case. - RecGetGlobalRawStatSum(aio_rsb, id, &sum); - RecGetGlobalRawStatCount(aio_rsb, id, &count); - - int64_t time_diff = ink_hrtime_to_msec(now - count); - if (time_diff == 0) { - data->rec_float = 0.0; - return 0; - } - switch (id) { - case AIO_STAT_READ_PER_SEC: - new_val = aio_num_read.load(); - break; - case AIO_STAT_WRITE_PER_SEC: - new_val = aio_num_write.load(); - break; - case AIO_STAT_KB_READ_PER_SEC: - new_val = aio_bytes_read.load() >> 10; - break; - case AIO_STAT_KB_WRITE_PER_SEC: - new_val = aio_bytes_written.load() >> 10; - break; -#if TS_USE_LINUX_IO_URING - case AIO_STAT_IO_URING_SUBMITTED: - new_val = io_uring_submissions.load(); - break; - case AIO_STAT_IO_URING_COMPLETED: - new_val = io_uring_completions.load(); - break; -#endif - default: - ink_assert(0); - } - diff = new_val - sum; - RecSetGlobalRawStatSum(aio_rsb, id, new_val); - RecSetGlobalRawStatCount(aio_rsb, id, now); - data->rec_float = static_cast(diff) * 1000.00 / static_cast(time_diff); - return 0; -} #ifdef AIO_STATS /* total number of requests received - for debugging */ @@ -167,20 +106,16 @@ ink_aio_init(ts::ModuleVersion v, AIOBackend backend) { ink_release_assert(v.check(AIO_MODULE_INTERNAL_VERSION)); - aio_rsb = RecAllocateRawStatBlock(static_cast(AIO_STAT_COUNT)); - RecRegisterRawStat(aio_rsb, RECT_PROCESS, "proxy.process.cache.read_per_sec", RECD_FLOAT, RECP_PERSISTENT, - (int)AIO_STAT_READ_PER_SEC, aio_stats_cb); - RecRegisterRawStat(aio_rsb, RECT_PROCESS, "proxy.process.cache.write_per_sec", RECD_FLOAT, RECP_PERSISTENT, - (int)AIO_STAT_WRITE_PER_SEC, aio_stats_cb); - RecRegisterRawStat(aio_rsb, RECT_PROCESS, "proxy.process.cache.KB_read_per_sec", RECD_FLOAT, RECP_PERSISTENT, - (int)AIO_STAT_KB_READ_PER_SEC, aio_stats_cb); - RecRegisterRawStat(aio_rsb, RECT_PROCESS, "proxy.process.cache.KB_write_per_sec", RECD_FLOAT, RECP_PERSISTENT, - (int)AIO_STAT_KB_WRITE_PER_SEC, aio_stats_cb); + 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"); + #if TS_USE_LINUX_IO_URING - RecRegisterRawStat(aio_rsb, RECT_PROCESS, "proxy.process.io_uring.submitted", RECD_FLOAT, RECP_PERSISTENT, - (int)AIO_STAT_IO_URING_SUBMITTED, aio_stats_cb); - RecRegisterRawStat(aio_rsb, RECT_PROCESS, "proxy.process.io_uring.completed", RECD_FLOAT, RECP_PERSISTENT, - (int)AIO_STAT_IO_URING_COMPLETED, aio_stats_cb); + aio_rsb.io_uring_submitted = intm.newMetricPtr("proxy.process.io_uring.submitted"); + aio_rsb.io_uring_completed = intm.newMetricPtr("proxy.process.io_uring.completed"); #endif memset(&aio_reqs, 0, MAX_DISKS_POSSIBLE * sizeof(AIO_Reqs *)); @@ -511,11 +446,11 @@ AIOThreadInfo::aio_thread_main(AIOThreadInfo *thr_info) #endif // update the stats; if (op->aiocb.aio_lio_opcode == LIO_WRITE) { - aio_num_write.fetch_add(1); - aio_bytes_written.fetch_add(op->aiocb.aio_nbytes); + Metrics::increment(aio_rsb.write_count); + Metrics::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); } else { - aio_num_read.fetch_add(1); - aio_bytes_read.fetch_add(op->aiocb.aio_nbytes); + Metrics::increment(aio_rsb.read_count); + Metrics::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); } ink_mutex_release(¤t_req->aio_mutex); cache_op((AIOCallbackInternal *)op); @@ -648,11 +583,11 @@ AIOCallbackInternal::handle_complete(io_uring_cqe *cqe) if (op->aio_result > 0) { if (op->aiocb.aio_lio_opcode == LIO_WRITE) { - aio_num_write.fetch_add(1); - aio_bytes_written.fetch_add(op->aiocb.aio_nbytes); + Metrics::increment(aio_rsb.write_count); + Metrics::increment(aio_rsb.kb_write, op->aiocb.aio_nbytes >> 10); } else { - aio_num_read.fetch_add(1); - aio_bytes_read.fetch_add(op->aiocb.aio_nbytes); + Metrics::increment(aio_rsb.read_count); + Metrics::increment(aio_rsb.kb_read, op->aiocb.aio_nbytes >> 10); } } diff --git a/iocore/aio/Makefile.am b/iocore/aio/Makefile.am index 450a212a56a..63c6e238553 100644 --- a/iocore/aio/Makefile.am +++ b/iocore/aio/Makefile.am @@ -55,8 +55,8 @@ test_AIO_CPPFLAGS = \ test_AIO_LDADD = \ libinkaio.a \ - $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ + $(top_builddir)/src/records/librecords_p.a \ $(top_builddir)/src/tscore/libtscore.a \ $(top_builddir)/src/api/libtsapicore.a \ $(top_builddir)/src/tscpp/util/libtscpputil.la \ diff --git a/iocore/aio/P_AIO.h b/iocore/aio/P_AIO.h index c8c6eef6338..2f794e7054c 100644 --- a/iocore/aio/P_AIO.h +++ b/iocore/aio/P_AIO.h @@ -37,6 +37,10 @@ #include "I_IO_URING.h" #endif +#include "api/Metrics.h" + +using ts::Metrics; + // for debugging // #define AIO_STATS 1 @@ -128,15 +132,16 @@ class AIOTestData : public Continuation }; #endif -enum aio_stat_enum { - AIO_STAT_READ_PER_SEC, - AIO_STAT_KB_READ_PER_SEC, - AIO_STAT_WRITE_PER_SEC, - AIO_STAT_KB_WRITE_PER_SEC, +struct AIOStatsBlock { + Metrics::IntType *read_count; + Metrics::IntType *kb_read; + Metrics::IntType *write_count; + Metrics::IntType *kb_write; + #if TS_USE_LINUX_IO_URING - AIO_STAT_IO_URING_SUBMITTED, - AIO_STAT_IO_URING_COMPLETED, + Metrics::IntType *io_uring_submitted; + Metrics::IntType *io_uring_completed; #endif - AIO_STAT_COUNT }; -extern RecRawStatBlock *aio_rsb; + +extern AIOStatsBlock aio_rsb; diff --git a/iocore/aio/test_AIO.cc b/iocore/aio/test_AIO.cc index 498162b2410..7f11f133781 100644 --- a/iocore/aio/test_AIO.cc +++ b/iocore/aio/test_AIO.cc @@ -220,8 +220,8 @@ dump_summary() printf("-----------------\n"); printf("IO_URING results\n"); printf("-----------------\n"); - printf("submissions: %lu\n", io_uring_submissions.load()); - printf("completions: %lu\n", io_uring_completions.load()); + printf("submissions: %lu\n", Metrics::read(aio_rsb.io_uring_submitted); + printf("completions: %lu\n", Metrics::read(aio_rsb.io_uring_completed); #endif if (delete_disks) { diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc index 9233da2b0f0..b20c428210e 100644 --- a/iocore/cache/Cache.cc +++ b/iocore/cache/Cache.cc @@ -36,6 +36,7 @@ #include "api/InkAPIInternal.h" #include "tscore/hugepages.h" +#include "records/P_RecProcess.h" #ifdef AIO_FAULT_INJECTION #include "AIO_fault_injection.h" @@ -54,12 +55,6 @@ static size_t DEFAULT_RAM_CACHE_MULTIPLIER = 10; // I.e. 10x 1MB per 1GB of disk // This is the oldest version number that is still usable. static short int const CACHE_DB_MAJOR_VERSION_COMPATIBLE = 21; -#define DOCACHE_CLEAR_DYN_STAT(x) \ - do { \ - RecSetRawStatSum(rsb, x, 0); \ - RecSetRawStatCount(rsb, x, 0); \ - } while (0); - // Configuration int64_t cache_config_ram_cache_size = AUTO_SIZE_RAM_CACHE; @@ -90,7 +85,7 @@ int cache_config_read_while_writer_max_retries = 10; // Globals -RecRawStatBlock *cache_rsb = nullptr; +CacheStatsBlock cache_rsb; Cache *theCache = nullptr; CacheDisk **gdisks = nullptr; int gndisks = 0; @@ -162,7 +157,6 @@ static void cplist_update(); int cplist_reconfigure(); static int create_volume(int volume_number, off_t size_in_blocks, int scheme, CacheVol *cp); static void rebuild_host_table(Cache *cache); -void register_cache_stats(RecRawStatBlock *rsb, const char *prefix); // Global list of the volumes created Queue cp_list; @@ -177,51 +171,117 @@ force_link_CacheTestCaller() } #endif -int64_t -cache_bytes_used(int volume) -{ - uint64_t used = 0; - - for (int i = 0; i < gnvol; i++) { - if (!DISK_BAD(gvol[i]->disk) && (volume == -1 || gvol[i]->cache_vol->vol_number == volume)) { - if (!gvol[i]->header->cycle) { - used += gvol[i]->header->write_pos - gvol[i]->start; - } else { - used += gvol[i]->len - gvol[i]->dirlen() - EVACUATION_SIZE; - } +// Register Stats, this handles both the global cache metrics, as well as the per volume metrics. +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"); + + // 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+"); + + // 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"); + 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 + ".directory.wrap.around"); + rsb->directory_sync_count = intm.newMetricPtr(prefix + ".directory.sync.count"); + rsb->directory_sync_bytes = intm.newMetricPtr(prefix + ".directory.sync.bytes"); + rsb->directory_sync_time = intm.newMetricPtr(prefix + ".directory.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"); +} + +// ToDo: This gets called as part of librecords collection continuation, probably change this later. +inline int64_t +cache_bytes_used(int vol_ix) +{ + if (!DISK_BAD(gvol[vol_ix]->disk)) { + if (!gvol[vol_ix]->header->cycle) { + return gvol[vol_ix]->header->write_pos - gvol[vol_ix]->start; + } else { + return gvol[vol_ix]->len - gvol[vol_ix]->dirlen() - EVACUATION_SIZE; } } - return used; + return 0; } -int -cache_stats_bytes_used_cb(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id) +void +CachePeriodicMetricsUpdate() { - int volume = -1; - char *p; + int64_t total_sum = 0; - // Well, there's no way to pass along the volume ID, so extracting it from the stat name. - p = strstr(const_cast(name), "volume_"); - if (p != nullptr) { - // I'm counting on the compiler to optimize out strlen("volume_"). - volume = strtol(p + strlen("volume_"), nullptr, 10); + // Make sure the bytes_used per volume is always reset to zero, this can update the + // 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); } if (cacheProcessor.initialized == CACHE_INITIALIZED) { - int64_t used, total = 0; - float percent_full; + for (int vol_ix = 0; vol_ix < gnvol; ++vol_ix) { + Vol *v = gvol[vol_ix]; + int64_t used = cache_bytes_used(vol_ix); - used = cache_bytes_used(volume); - RecSetGlobalRawStatSum(rsb, id, used); - RecRawStatSyncSum(name, data_type, data, rsb, id); - RecGetGlobalRawStatSum(rsb, static_cast(cache_bytes_total_stat), &total); - percent_full = static_cast(used) / static_cast(total) * 100; - // The percent_full float below gets rounded down - RecSetGlobalRawStatSum(rsb, static_cast(cache_percent_full_stat), static_cast(percent_full)); - } + Metrics::increment(v->cache_vol->vol_rsb.bytes_used, used); // This assumes they start at zero + total_sum += used; + } - return 1; + // Also update the global (not per volume) metrics + int64_t total = Metrics::read(cache_rsb.bytes_total); + + Metrics::write(cache_rsb.bytes_used, total_sum); + Metrics::write(cache_rsb.percent_full, total ? (total_sum * 100) / total : 0); + } } static int @@ -531,6 +591,8 @@ Vol::close_read(CacheVC *cont) const int CacheProcessor::start(int, size_t) { + RecRegNewSyncStatSync(CachePeriodicMetricsUpdate); + return start_internal(0); } @@ -656,8 +718,8 @@ CacheProcessor::start_internal(int flags) } // It's actually common that the hardware I/O size is larger than the store block size as - // storage systems increasingly want larger I/Os. For example, on macOS, the filesystem block - // size is always reported as 1MB. + // storage systems increasingly want larger I/Os. For example, on macOS, the filesystem + // block size is always reported as 1MB. if (sd->hw_sector_size <= 0 || sector_size > STORE_BLOCK_SIZE) { Note("resetting hardware sector size from %d to %d", sector_size, STORE_BLOCK_SIZE); sector_size = STORE_BLOCK_SIZE; @@ -751,8 +813,8 @@ CacheProcessor::diskInitialized() gndisks -= bad_disks; // Check if this is a fatal error if (this->waitForCache() == 3 || (0 == gndisks && this->waitForCache() == 2)) { - // This could be passed off to @c cacheInitialized (as with volume config problems) but I think - // the more specific error message here is worth the extra code. + // This could be passed off to @c cacheInitialized (as with volume config problems) but I + // think the more specific error message here is worth the extra code. CacheProcessor::initialized = CACHE_INIT_FAILED; if (cb_after_init) { cb_after_init(); @@ -764,9 +826,10 @@ CacheProcessor::diskInitialized() } /* Practically just took all bad_disks offline so update the stats. */ - RecSetGlobalRawStatSum(cache_rsb, cache_span_offline_stat, bad_disks); - RecIncrGlobalRawStat(cache_rsb, cache_span_failing_stat, -bad_disks); - RecSetGlobalRawStatSum(cache_rsb, cache_span_online_stat, gndisks); + // 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); /* create the cachevol list only if num volumes are greater than 0. */ if (config_volumes.num_volumes == 0) { @@ -788,10 +851,10 @@ CacheProcessor::diskInitialized() } else { CacheVol *cp = cp_list.head; for (; cp; cp = cp->link.next) { - cp->vol_rsb = RecAllocateRawStatBlock(static_cast(cache_stat_count)); char vol_stat_str_prefix[256]; + snprintf(vol_stat_str_prefix, sizeof(vol_stat_str_prefix), "proxy.process.cache.volume_%d", cp->vol_number); - register_cache_stats(cp->vol_rsb, vol_stat_str_prefix); + register_cache_stats(&cp->vol_rsb, vol_stat_str_prefix); } } @@ -851,14 +914,13 @@ CacheProcessor::cacheInitialized() uint64_t vol_used_direntries = 0; Vol *vol; - ProxyMutex *mutex = this_ethread()->mutex.get(); - if (theCache) { total_size += theCache->cache_size; Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - theCache, total_size = %" PRId64 " = %" PRId64 " MB", total_size, total_size / ((1024 * 1024) / STORE_BLOCK_SIZE)); if (theCache->ready == CACHE_INIT_FAILED) { - Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - failed to initialize the cache for http: cache disabled"); + Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - failed to initialize the cache " + "for http: cache disabled"); Warning("failed to initialize the cache for http: cache disabled\n"); } else { caches_ready = caches_ready | (1 << CACHE_FRAG_TYPE_HTTP); @@ -913,21 +975,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)); - CACHE_VOL_SUM_DYN_STAT(cache_ram_cache_bytes_total_stat, (int64_t)gvol[i]->dirlen()); + Metrics::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)); - CACHE_VOL_SUM_DYN_STAT(cache_bytes_total_stat, vol_total_cache_bytes); + Metrics::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; - CACHE_VOL_SUM_DYN_STAT(cache_direntries_total_stat, vol_total_direntries); + Metrics::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - CACHE_VOL_SUM_DYN_STAT(cache_direntries_used_stat, vol_used_direntries); + Metrics::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } @@ -960,7 +1022,7 @@ CacheProcessor::cacheInitialized() Dbg(dbg_ctl_cache_init, "CacheProcessor::cacheInitialized - factor = %f", factor); gvol[i]->ram_cache->init(static_cast(http_ram_cache_size * factor), vol); ram_cache_bytes += static_cast(http_ram_cache_size * factor); - CACHE_VOL_SUM_DYN_STAT(cache_ram_cache_bytes_total_stat, (int64_t)(http_ram_cache_size * factor)); + Metrics::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"); } @@ -968,17 +1030,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; - CACHE_VOL_SUM_DYN_STAT(cache_bytes_total_stat, vol_total_cache_bytes); - CACHE_VOL_SUM_DYN_STAT(cache_stripes_stat, 1); // Count the cache stripes + Metrics::increment(vol->cache_vol->vol_rsb.bytes_total, vol_total_cache_bytes); + Metrics::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; - CACHE_VOL_SUM_DYN_STAT(cache_direntries_total_stat, vol_total_direntries); + Metrics::increment(vol->cache_vol->vol_rsb.direntries_total, vol_total_direntries); vol_used_direntries = dir_entries_used(gvol[i]); - CACHE_VOL_SUM_DYN_STAT(cache_direntries_used_stat, vol_used_direntries); + Metrics::increment(vol->cache_vol->vol_rsb.direntries_used, vol_used_direntries); used_direntries += vol_used_direntries; } } @@ -997,10 +1059,11 @@ CacheProcessor::cacheInitialized() break; } - GLOBAL_CACHE_SET_DYN_STAT(cache_ram_cache_bytes_total_stat, ram_cache_bytes); - GLOBAL_CACHE_SET_DYN_STAT(cache_bytes_total_stat, total_cache_bytes); - GLOBAL_CACHE_SET_DYN_STAT(cache_direntries_total_stat, total_direntries); - GLOBAL_CACHE_SET_DYN_STAT(cache_direntries_used_stat, used_direntries); + 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); + if (!check) { dir_sync_init(); } @@ -1894,14 +1957,14 @@ CacheProcessor::mark_storage_offline(CacheDisk *d, ///< Target disk } } - RecIncrGlobalRawStat(cache_rsb, cache_bytes_total_stat, -total_bytes_delete); - RecIncrGlobalRawStat(cache_rsb, cache_direntries_total_stat, -total_dir_delete); - RecIncrGlobalRawStat(cache_rsb, cache_direntries_used_stat, -used_dir_delete); + 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); /* 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 */ - RecIncrGlobalRawStat(cache_rsb, admin ? cache_span_online_stat : cache_span_failing_stat, -1); - RecIncrGlobalRawStat(cache_rsb, cache_span_offline_stat, 1); + Metrics::decrement(admin ? cache_rsb.span_online : cache_rsb.span_failing); + Metrics::increment(cache_rsb.span_offline); if (theCache) { rebuild_host_table(theCache); @@ -2277,7 +2340,13 @@ CacheVC::handleRead(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) io.thread = mutex->thread_holding->tt == DEDICATED ? AIO_CALLBACK_THREAD_ANY : mutex->thread_holding; SET_HANDLER(&CacheVC::handleReadDone); ink_assert(ink_aio_read(&io) >= 0); - CACHE_DEBUG_INCREMENT_DYN_STAT(cache_pread_count_stat); + +// ToDo: Why are these for debug only ?? +#if DEBUG + Metrics::increment(cache_rsb.pread_count); + Metrics::increment(vol->cache_vol->vol_rsb.pread_count); +#endif + return EVENT_CONT; LramHit : { @@ -2304,13 +2373,13 @@ Cache::lookup(Continuation *cont, const CacheKey *key, CacheFragType type, const return ACTION_RESULT_DONE; } - Vol *vol = key_to_vol(key, hostname, host_len); - ProxyMutex *mutex = cont->mutex.get(); - CacheVC *c = new_CacheVC(cont); + Vol *vol = key_to_vol(key, hostname, host_len); + CacheVC *c = new_CacheVC(cont); SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); - c->vio.op = VIO::READ; - c->base_stat = cache_lookup_active_stat; - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); + 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); c->first_key = c->key = *key; c->frag_type = type; c->f.lookup = 1; @@ -2392,7 +2461,8 @@ CacheVC::removeEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) return ret; } Ldone: - CACHE_INCREMENT_DYN_STAT(cache_remove_failure_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Remove)].failure); + Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Remove)].failure); if (od) { vol->close_write(this); } @@ -2432,8 +2502,9 @@ Cache::remove(Continuation *cont, const CacheKey *key, CacheFragType type, const CacheVC *c = new_CacheVC(cont); c->vio.op = VIO::NONE; c->frag_type = type; - c->base_stat = cache_remove_active_stat; - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); + 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); c->first_key = c->key = *key; c->vol = vol; c->dir = result; @@ -2553,8 +2624,9 @@ cplist_update() // before any other new volumes to assure proper span free space calculation and proper volume block distribution. for (config_vol = config_volumes.cp_queue.head; config_vol; config_vol = config_vol->link.next) { if (nullptr == config_vol->cachep) { - // Find out if this is a forced volume assigned exclusively to a span which was cleared (hence not referenced in cp_list). - // Note: non-exclusive cleared spans are not handled here, only the "exclusive" + // Find out if this is a forced volume assigned exclusively to a span which was cleared (hence + // not referenced in cp_list). Note: non-exclusive cleared spans are not handled here, only + // the "exclusive" bool forced_volume = false; for (int d_no = 0; d_no < gndisks; d_no++) { if (gdisks[d_no]->forced_volume_num == config_vol->number) { @@ -2610,7 +2682,8 @@ fillExclusiveDisks(CacheVol *cp) } if (found_nonforced_volumes) { - /* The user had created several volumes before - clear the disk and create one volume for http */ + /* The user had created several volumes before - clear the disk and create one volume for http + */ Note("Clearing Disk: %s", gdisks[i]->path); gdisks[i]->delete_all_volumes(); } else if (1 == gdisks[i]->header->num_volumes) { @@ -2722,7 +2795,8 @@ cplist_reconfigure() } // Find if the volume is forced and if it is then calculate the total forced volume size. - // Forced volumes take the whole span (disk) also sum all disk space this volume is forced to. + // Forced volumes take the whole span (disk) also sum all disk space this volume is forced + // to. int64_t tot_forced_space_in_blks = 0; for (int i = 0; i < gndisks; i++) { if (config_vol->number == gdisks[i]->forced_volume_num) { @@ -2877,7 +2951,7 @@ cplist_reconfigure() } } - GLOBAL_CACHE_SET_DYN_STAT(cache_stripes_stat, gnvol + assignedVol); + Metrics::write(cache_rsb.stripes, gnvol + assignedVol); return 0; } @@ -3001,80 +3075,6 @@ Cache::key_to_vol(const CacheKey *key, const char *hostname, int host_len) } } -static void -reg_int(const char *str, int stat, RecRawStatBlock *rsb, const char *prefix, RecRawStatSyncCb sync_cb = RecRawStatSyncSum) -{ - char stat_str[256]; - snprintf(stat_str, sizeof(stat_str), "%s.%s", prefix, str); - RecRegisterRawStat(rsb, RECT_PROCESS, stat_str, RECD_INT, RECP_NON_PERSISTENT, stat, sync_cb); - DOCACHE_CLEAR_DYN_STAT(stat) -} -#define REG_INT(_str, _stat) reg_int(_str, (int)_stat, rsb, prefix) - -// Register Stats -void -register_cache_stats(RecRawStatBlock *rsb, const char *prefix) -{ - // Special case for this sucker, since it uses its own aggregator. - reg_int("bytes_used", cache_bytes_used_stat, rsb, prefix, cache_stats_bytes_used_cb); - - REG_INT("bytes_total", cache_bytes_total_stat); - REG_INT("stripes", cache_stripes_stat); - REG_INT("ram_cache.total_bytes", cache_ram_cache_bytes_total_stat); - REG_INT("ram_cache.bytes_used", cache_ram_cache_bytes_stat); - REG_INT("ram_cache.hits", cache_ram_cache_hits_stat); - REG_INT("ram_cache.misses", cache_ram_cache_misses_stat); - REG_INT("pread_count", cache_pread_count_stat); - REG_INT("percent_full", cache_percent_full_stat); - REG_INT("lookup.active", cache_lookup_active_stat); - REG_INT("lookup.success", cache_lookup_success_stat); - REG_INT("lookup.failure", cache_lookup_failure_stat); - REG_INT("read.active", cache_read_active_stat); - REG_INT("read.success", cache_read_success_stat); - REG_INT("read.failure", cache_read_failure_stat); - REG_INT("read.seek.failure", cache_read_seek_fail_stat); - REG_INT("read.invalid", cache_read_invalid_stat); - REG_INT("write.active", cache_write_active_stat); - REG_INT("write.success", cache_write_success_stat); - REG_INT("write.failure", cache_write_failure_stat); - REG_INT("write.backlog.failure", cache_write_backlog_failure_stat); - REG_INT("update.active", cache_update_active_stat); - REG_INT("update.success", cache_update_success_stat); - REG_INT("update.failure", cache_update_failure_stat); - REG_INT("remove.active", cache_remove_active_stat); - REG_INT("remove.success", cache_remove_success_stat); - REG_INT("remove.failure", cache_remove_failure_stat); - REG_INT("evacuate.active", cache_evacuate_active_stat); - REG_INT("evacuate.success", cache_evacuate_success_stat); - REG_INT("evacuate.failure", cache_evacuate_failure_stat); - REG_INT("scan.active", cache_scan_active_stat); - REG_INT("scan.success", cache_scan_success_stat); - REG_INT("scan.failure", cache_scan_failure_stat); - REG_INT("direntries.total", cache_direntries_total_stat); - REG_INT("direntries.used", cache_direntries_used_stat); - REG_INT("directory_collision", cache_directory_collision_count_stat); - REG_INT("frags_per_doc.1", cache_single_fragment_document_count_stat); - REG_INT("frags_per_doc.2", cache_two_fragment_document_count_stat); - REG_INT("frags_per_doc.3+", cache_three_plus_plus_fragment_document_count_stat); - REG_INT("read_busy.success", cache_read_busy_success_stat); - REG_INT("read_busy.failure", cache_read_busy_failure_stat); - REG_INT("write_bytes_stat", cache_write_bytes_stat); - REG_INT("vector_marshals", cache_hdr_vector_marshal_stat); - REG_INT("hdr_marshals", cache_hdr_marshal_stat); - REG_INT("hdr_marshal_bytes", cache_hdr_marshal_bytes_stat); - REG_INT("gc_bytes_evacuated", cache_gc_bytes_evacuated_stat); - REG_INT("gc_frags_evacuated", cache_gc_frags_evacuated_stat); - REG_INT("wrap_count", cache_directory_wrap_stat); - REG_INT("sync.count", cache_directory_sync_count_stat); - REG_INT("sync.bytes", cache_directory_sync_bytes_stat); - REG_INT("sync.time", cache_directory_sync_time_stat); - REG_INT("span.errors.read", cache_span_errors_read_stat); - REG_INT("span.errors.write", cache_span_errors_write_stat); - REG_INT("span.failing", cache_span_failing_stat); - REG_INT("span.offline", cache_span_offline_stat); - REG_INT("span.online", cache_span_online_stat); -} - int FragmentSizeUpdateCb(const char * /* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, RecData data, void *cookie) { @@ -3092,8 +3092,6 @@ ink_cache_init(ts::ModuleVersion v) { ink_release_assert(v.check(CACHE_MODULE_VERSION)); - cache_rsb = RecAllocateRawStatBlock(static_cast(cache_stat_count)); - REC_EstablishStaticConfigInteger(cache_config_ram_cache_size, "proxy.config.cache.ram_cache.size"); Dbg(dbg_ctl_cache_init, "proxy.config.cache.ram_cache.size = %" PRId64 " = %" PRId64 "Mb", cache_config_ram_cache_size, cache_config_ram_cache_size / (1024 * 1024)); @@ -3168,7 +3166,7 @@ ink_cache_init(ts::ModuleVersion v) REC_RegisterConfigUpdateFunc("proxy.config.cache.enable_read_while_writer", update_cache_config, nullptr); Dbg(dbg_ctl_cache_init, "proxy.config.cache.enable_read_while_writer = %d", cache_config_read_while_writer); - register_cache_stats(cache_rsb, "proxy.process.cache"); + register_cache_stats(&cache_rsb, "proxy.process.cache"); REC_ReadConfigInteger(cacheProcessor.wait_for_cache, "proxy.config.http.wait_for_cache"); diff --git a/iocore/cache/CacheDir.cc b/iocore/cache/CacheDir.cc index 4e6f04a37b2..234adc904d9 100644 --- a/iocore/cache/CacheDir.cc +++ b/iocore/cache/CacheDir.cc @@ -33,24 +33,6 @@ #endif #include "tscore/ink_stack_trace.h" -#define CACHE_INC_DIR_USED(_m) \ - do { \ - ProxyMutex *mutex = _m.get(); \ - CACHE_INCREMENT_DYN_STAT(cache_direntries_used_stat); \ - } while (0) - -#define CACHE_DEC_DIR_USED(_m) \ - do { \ - ProxyMutex *mutex = _m.get(); \ - CACHE_DECREMENT_DYN_STAT(cache_direntries_used_stat); \ - } while (0) - -#define CACHE_INC_DIR_COLLISIONS(_m) \ - do { \ - ProxyMutex *mutex = _m.get(); \ - CACHE_INCREMENT_DYN_STAT(cache_directory_collision_count_stat); \ - } while (0); - namespace { @@ -387,7 +369,8 @@ dir_clean_bucket(Dir *b, int s, Vol *vol) dir_tag(e), dir_offset(e), b, p, dir_bucket_length(b, s, vol)); } if (dir_offset(e)) { - CACHE_DEC_DIR_USED(vol->mutex); + Metrics::decrement(cache_rsb.direntries_used); + Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); } e = dir_delete_entry(e, p, s, vol); continue; @@ -422,7 +405,8 @@ dir_clear_range(off_t start, off_t end, Vol *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)) { - CACHE_DEC_DIR_USED(vol->mutex); + Metrics::decrement(cache_rsb.direntries_used); + Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -457,7 +441,8 @@ freelist_clean(int s, Vol *vol) for (int l = 0; l < DIR_DEPTH; l++) { Dir *e = dir_bucket_row(b, l); if (dir_head(e) && !(n++ % 10)) { - CACHE_DEC_DIR_USED(vol->mutex); + Metrics::decrement(cache_rsb.direntries_used); + Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_set_offset(e, 0); // delete } } @@ -584,7 +569,8 @@ dir_probe(const CacheKey *key, Vol *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"); - CACHE_INC_DIR_COLLISIONS(vol->mutex); + Metrics::increment(cache_rsb.directory_collision_count); + Metrics::increment(vol->cache_vol->vol_rsb.directory_collision_count); } goto Lcont; } @@ -596,7 +582,8 @@ dir_probe(const CacheKey *key, Vol *vol, Dir *result, Dir **last_collision) ink_assert(dir_offset(e) * CACHE_BLOCK_SIZE < vol->len); return 1; } else { // delete the invalid entry - CACHE_DEC_DIR_USED(vol->mutex); + Metrics::decrement(cache_rsb.direntries_used); + Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); e = dir_delete_entry(e, p, s, vol); continue; } @@ -610,7 +597,8 @@ dir_probe(const CacheKey *key, Vol *vol, Dir *result, Dir **last_collision) } if (collision) { // last collision no longer in the list, retry DDbg(dbg_ctl_cache_stats, "Incrementing dir collisions"); - CACHE_INC_DIR_COLLISIONS(vol->mutex); + Metrics::increment(cache_rsb.directory_collision_count); + Metrics::increment(vol->cache_vol->vol_rsb.directory_collision_count); collision = nullptr; goto Lagain; } @@ -681,7 +669,9 @@ dir_insert(const CacheKey *key, Vol *vol, Dir *to_part) bi, e, key->slice32(1), dir_tag(e), dir_offset(e)); CHECK_DIR(d); vol->header->dirty = 1; - CACHE_INC_DIR_USED(vol->mutex); + Metrics::increment(cache_rsb.direntries_used); + Metrics::increment(vol->cache_vol->vol_rsb.direntries_used); + return 1; } @@ -730,7 +720,8 @@ dir_overwrite(const CacheKey *key, Vol *vol, Dir *dir, Dir *overwrite, bool must // get from this row first e = b; if (dir_is_empty(e)) { - CACHE_INC_DIR_USED(vol->mutex); + Metrics::increment(cache_rsb.direntries_used); + Metrics::increment(vol->cache_vol->vol_rsb.direntries_used); goto Lfill; } for (l = 1; l < DIR_DEPTH; l++) { @@ -746,7 +737,8 @@ dir_overwrite(const CacheKey *key, Vol *vol, Dir *dir, Dir *overwrite, bool must goto Lagain; } Llink: - CACHE_INC_DIR_USED(vol->mutex); + Metrics::increment(cache_rsb.direntries_used); + Metrics::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; @@ -794,7 +786,8 @@ dir_delete(const CacheKey *key, Vol *vol, Dir *del) } #endif if (dir_compare_tag(e, key) && dir_offset(e) == dir_offset(del)) { - CACHE_DEC_DIR_USED(vol->mutex); + Metrics::decrement(cache_rsb.direntries_used); + Metrics::decrement(vol->cache_vol->vol_rsb.direntries_used); dir_delete_entry(e, p, s, vol); CHECK_DIR(d); return 1; @@ -1108,8 +1101,8 @@ CacheSync::mainEvent(int event, Event *e) event = EVENT_NONE; goto Ldone; } - CACHE_SUM_DYN_STAT(cache_directory_sync_bytes_stat, io.aio_result); - + Metrics::increment(cache_rsb.directory_sync_bytes, io.aio_result); + Metrics::increment(vol->cache_vol->vol_rsb.directory_sync_bytes, io.aio_result); trigger = eventProcessor.schedule_in(this, SYNC_DELAY); return EVENT_CONT; } @@ -1202,8 +1195,10 @@ CacheSync::mainEvent(int event, Event *e) writepos += headerlen; } else { vol->dir_sync_in_progress = false; - CACHE_INCREMENT_DYN_STAT(cache_directory_sync_count_stat); - CACHE_SUM_DYN_STAT(cache_directory_sync_time_stat, ink_get_hrtime() - start_time); + 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); start_time = 0; goto Ldone; } diff --git a/iocore/cache/CacheDisk.cc b/iocore/cache/CacheDisk.cc index 4b7b66d1e97..9e156f72696 100644 --- a/iocore/cache/CacheDisk.cc +++ b/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. */ - RecIncrGlobalRawStat(cache_rsb, static_cast(cache_span_online_stat), -1); - RecIncrGlobalRawStat(cache_rsb, static_cast(cache_span_failing_stat), 1); + Metrics::decrement(cache_rsb.span_online); + Metrics::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"; - RecIncrGlobalRawStat(cache_rsb, static_cast(cache_span_errors_read_stat), 1); + Metrics::increment(cache_rsb.span_errors_read); break; case LIO_WRITE: opname = "WRITE"; - RecIncrGlobalRawStat(cache_rsb, static_cast(cache_span_errors_write_stat), 1); + Metrics::increment(cache_rsb.span_errors_write); break; default: break; diff --git a/iocore/cache/CacheHttp.cc b/iocore/cache/CacheHttp.cc index 7843f8d806e..264905b47e9 100644 --- a/iocore/cache/CacheHttp.cc +++ b/iocore/cache/CacheHttp.cc @@ -191,9 +191,10 @@ CacheHTTPInfoVector::marshal(char *buf, int length) count++; } - GLOBAL_CACHE_SUM_GLOBAL_DYN_STAT(cache_hdr_vector_marshal_stat, 1); - GLOBAL_CACHE_SUM_GLOBAL_DYN_STAT(cache_hdr_marshal_stat, count); - GLOBAL_CACHE_SUM_GLOBAL_DYN_STAT(cache_hdr_marshal_bytes_stat, buf - start); + Metrics::increment(cache_rsb.hdr_vector_marshal); + Metrics::increment(cache_rsb.hdr_marshal, count); + Metrics::increment(cache_rsb.hdr_marshal_bytes, buf - start); + return buf - start; } diff --git a/iocore/cache/CacheRead.cc b/iocore/cache/CacheRead.cc index 1e27fc5f2f7..e10b2c0c9c9 100644 --- a/iocore/cache/CacheRead.cc +++ b/iocore/cache/CacheRead.cc @@ -59,9 +59,10 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, co if (!lock.is_locked() || (od = vol->open_read(key)) || dir_probe(key, vol, &result, &last_collision)) { c = new_CacheVC(cont); SET_CONTINUATION_HANDLER(c, &CacheVC::openReadStartHead); - c->vio.op = VIO::READ; - c->base_stat = cache_read_active_stat; - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); + 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); c->first_key = c->key = c->earliest_key = *key; c->vol = vol; c->frag_type = type; @@ -89,7 +90,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, co } } Lmiss: - CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::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: @@ -128,8 +130,9 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr *request, c->first_key = c->key = c->earliest_key = *key; c->vol = vol; c->vio.op = VIO::READ; - c->base_stat = cache_read_active_stat; - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); + 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); c->request.copy_shallow(request); c->frag_type = CACHE_FRAG_TYPE_HTTP; c->params = params; @@ -160,7 +163,8 @@ Cache::open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr *request, } } Lmiss: - CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::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: @@ -199,8 +203,10 @@ CacheVC::openReadFromWriterFailure(int event, Event *e) { od = nullptr; vector.clear(false); - CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat); - CACHE_INCREMENT_DYN_STAT(cache_read_busy_failure_stat); + 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); _action.continuation->handleEvent(event, e); free_CacheVC(this); return EVENT_DONE; @@ -448,7 +454,9 @@ CacheVC::openReadFromWriter(int event, Event *e) dir_clean(&first_dir); dir_clean(&earliest_dir); SET_HANDLER(&CacheVC::openReadFromWriterMain); - CACHE_INCREMENT_DYN_STAT(cache_read_busy_success_stat); + Metrics::increment(cache_rsb.read_busy_success); + Metrics::increment(vol->cache_vol->vol_rsb.read_busy_success); + return callcont(CACHE_EVENT_OPEN_READ); } // want to snarf the new headers from the writer @@ -486,7 +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); - CACHE_INCREMENT_DYN_STAT(cache_read_busy_success_stat); + Metrics::increment(cache_rsb.read_busy_success); + Metrics::increment(vol->cache_vol->vol_rsb.read_busy_success); return callcont(CACHE_EVENT_OPEN_READ); } @@ -767,7 +776,8 @@ CacheVC::openReadMain(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) doc->magic = DOC_CORRUPT; - CACHE_INCREMENT_DYN_STAT(cache_read_seek_fail_stat); + Metrics::increment(cache_rsb.read_seek_fail); + Metrics::increment(vol->cache_vol->vol_rsb.read_seek_fail); CACHE_TRY_LOCK(lock, vol->mutex, mutex->thread_holding); if (!lock.is_locked()) { @@ -1004,14 +1014,16 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, Event * /* e ATS_UNUS vol->close_write(this); } } - CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::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) { - CACHE_INCREMENT_DYN_STAT(cache_read_busy_success_stat); + Metrics::increment(cache_rsb.read_busy_success); + Metrics::increment(vol->cache_vol->vol_rsb.read_busy_success); } SET_HANDLER(&CacheVC::openReadMain); return callcont(CACHE_EVENT_OPEN_READ); @@ -1062,7 +1074,8 @@ CacheVC::openReadVecWrite(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */ } } - CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::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: @@ -1203,7 +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); - CACHE_INCREMENT_DYN_STAT(cache_read_invalid_stat); + Metrics::increment(cache_rsb.read_invalid); + Metrics::increment(vol->cache_vol->vol_rsb.read_invalid); err = ECACHE_BAD_META_DATA; goto Ldone; } @@ -1268,10 +1282,12 @@ CacheVC::openReadStartHead(int event, Event *e) } Ldone: if (!f.lookup) { - CACHE_INCREMENT_DYN_STAT(cache_read_failure_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Read)].failure); + Metrics::increment(vol->cache_vol->vol_rsb.status[static_cast(CacheOpType::Read)].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-err); } else { - CACHE_INCREMENT_DYN_STAT(cache_lookup_failure_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Metrics::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); @@ -1281,7 +1297,8 @@ CacheVC::openReadStartHead(int event, Event *e) SET_HANDLER(&CacheVC::openReadMain); return callcont(CACHE_EVENT_OPEN_READ); Lookup: - CACHE_INCREMENT_DYN_STAT(cache_lookup_success_stat); + Metrics::increment(cache_rsb.status[static_cast(CacheOpType::Lookup)].failure); + Metrics::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/iocore/cache/CacheVol.cc b/iocore/cache/CacheVol.cc index 1613632868c..bb34aa32633 100644 --- a/iocore/cache/CacheVol.cc +++ b/iocore/cache/CacheVol.cc @@ -48,7 +48,7 @@ Cache::scan(Continuation *cont, const char *hostname, int host_len, int KB_per_s /* do we need to make a copy */ c->hostname = const_cast(hostname); c->host_len = host_len; - c->base_stat = cache_scan_active_stat; + c->op_type = static_cast(CacheOpType::Scan); c->buf = new_IOBufferData(BUFFER_SIZE_FOR_XMALLOC(SCAN_BUF_SIZE), MEMALIGNED); c->scan_msec_delay = (SCAN_BUF_SIZE / KB_per_second); c->offset = 0; diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc index 5df8cda6686..eeb96cfcc88 100644 --- a/iocore/cache/CacheWrite.cc +++ b/iocore/cache/CacheWrite.cc @@ -256,8 +256,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) { - CACHE_INCREMENT_DYN_STAT(cache_write_backlog_failure_stat); - CACHE_INCREMENT_DYN_STAT(base_stat + CACHE_STAT_FAILURE); + 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); vol->agg_todo_size -= agg_len; io.aio_result = AIO_SOFT_FAILURE; if (event == EVENT_CALL) { @@ -436,10 +438,10 @@ Vol::aggWriteDone(int event, Event *e) CacheVC * new_DocEvacuator(int nbytes, Vol *vol) { - CacheVC *c = new_CacheVC(vol); - ProxyMutex *mutex = vol->mutex.get(); - c->base_stat = cache_evacuate_active_stat; - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); + CacheVC *c = new_CacheVC(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); c->buf = new_IOBufferData(iobuffer_size_to_index(nbytes, MAX_BUFFER_SIZE_INDEX), MEMALIGNED); c->vol = vol; c->f.evacuator = 1; @@ -894,7 +896,12 @@ agg_copy(char *p, CacheVC *vc) { ProxyMutex *mutex ATS_UNUSED = vc->vol->mutex.get(); ink_assert(mutex->thread_holding == this_ethread()); - CACHE_DEBUG_SUM_DYN_STAT(cache_write_bytes_stat, vc->write_len); + +// 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); +#endif } if (vc->f.rewrite_resident_alt) { iobufferblock_memcpy(doc->data(), vc->write_len, res_alt_blk, 0); @@ -932,12 +939,11 @@ agg_copy(char *p, CacheVC *vc) // for evacuated documents, copy the data, and update directory Doc *doc = reinterpret_cast(vc->buf->data()); int l = vc->vol->round_to_approx_size(doc->len); - { - ProxyMutex *mutex ATS_UNUSED = vc->vol->mutex.get(); - ink_assert(mutex->thread_holding == this_ethread()); - CACHE_DEBUG_INCREMENT_DYN_STAT(cache_gc_frags_evacuated_stat); - CACHE_DEBUG_SUM_DYN_STAT(cache_gc_bytes_evacuated_stat, l); - } + +#ifdef DEBUG + Metrics::increment(cache_rsb.gc_frags_evacuated); + Metrics::increment(vol->cache_vol->vol_rsb.gc_frags_evacuated); +#endif doc->sync_serial = vc->vol->header->sync_serial; doc->write_serial = vc->vol->header->write_serial; @@ -1023,7 +1029,8 @@ Vol::agg_wrap() dir_clean_vol(this); { Vol *vol = this; - CACHE_INCREMENT_DYN_STAT(cache_directory_wrap_stat); + Metrics::increment(cache_rsb.directory_wrap); + Metrics::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(); @@ -1197,17 +1204,9 @@ CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED * // size of the document if ((closed == 1) && (total_len > 0 || f.allow_empty_doc)) { DDbg(dbg_ctl_cache_stats, "Fragment = %d", fragment); - switch (fragment) { - case 0: - CACHE_INCREMENT_DYN_STAT(cache_single_fragment_document_count_stat); - break; - case 1: - CACHE_INCREMENT_DYN_STAT(cache_two_fragment_document_count_stat); - break; - default: - CACHE_INCREMENT_DYN_STAT(cache_three_plus_plus_fragment_document_count_stat); - break; - } + + Metrics::increment(cache_rsb.fragment_document_count[std::max(fragment, 2)]); + Metrics::increment(vol->cache_vol->vol_rsb.fragment_document_count[std::max(fragment, 2)]); } if (f.close_complete) { recursive++; @@ -1658,7 +1657,8 @@ CacheVC::openWriteStartDone(int event, Event *e) return callcont(CACHE_EVENT_OPEN_WRITE); Lfailure: - CACHE_INCREMENT_DYN_STAT(base_stat + CACHE_STAT_FAILURE); + Metrics::increment(cache_rsb.status[op_type].failure); + Metrics::increment(vol->cache_vol->vol_rsb.status[op_type].failure); _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err); Lcancel: if (od) { @@ -1681,7 +1681,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)) { - CACHE_INCREMENT_DYN_STAT(base_stat + CACHE_STAT_FAILURE); + Metrics::increment(cache_rsb.status[op_type].failure); + Metrics::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; @@ -1711,15 +1712,15 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheFragType frag_ty ink_assert(caches[frag_type] == this); - intptr_t res = 0; - CacheVC *c = new_CacheVC(cont); - ProxyMutex *mutex = cont->mutex.get(); + intptr_t res = 0; + CacheVC *c = new_CacheVC(cont); SCOPED_MUTEX_LOCK(lock, c->mutex, this_ethread()); - c->vio.op = VIO::WRITE; - c->base_stat = cache_write_active_stat; - c->vol = key_to_vol(key, hostname, host_len); - Vol *vol = c->vol; - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); + c->vio.op = VIO::WRITE; + c->op_type = static_cast(CacheOpType::Write); + c->vol = key_to_vol(key, hostname, host_len); + Vol *vol = c->vol; + Metrics::increment(cache_rsb.status[c->op_type].active); + Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->first_key = c->key = *key; c->frag_type = frag_type; /* @@ -1741,7 +1742,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 - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_FAILURE); + Metrics::increment(cache_rsb.status[c->op_type].failure); + Metrics::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; @@ -1776,12 +1778,11 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, } ink_assert(caches[type] == this); - intptr_t err = 0; - int if_writers = (uintptr_t)info == CACHE_ALLOW_MULTIPLE_WRITES; - CacheVC *c = new_CacheVC(cont); - ProxyMutex *mutex = cont->mutex.get(); - c->vio.op = VIO::WRITE; - c->first_key = *key; + intptr_t err = 0; + int if_writers = (uintptr_t)info == CACHE_ALLOW_MULTIPLE_WRITES; + CacheVC *c = new_CacheVC(cont); + c->vio.op = VIO::WRITE; + c->first_key = *key; /* The transition from single fragment document to a multi-fragment document would cause a problem if the key and the first_key collide. In case of @@ -1827,16 +1828,18 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, open_write with info set close */ - c->f.update = 1; - c->base_stat = cache_update_active_stat; + c->f.update = 1; + c->op_type = static_cast(CacheOpType::Update); DDbg(dbg_ctl_cache_update, "Update called"); info->object_key_get(&c->update_key); ink_assert(!(c->update_key.is_zero())); c->update_len = info->object_size_get(); } else { - c->base_stat = cache_write_active_stat; + c->op_type = static_cast(CacheOpType::Write); } - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_ACTIVE); + + Metrics::increment(cache_rsb.status[c->op_type].active); + Metrics::increment(vol->cache_vol->vol_rsb.status[c->op_type].active); c->pin_in_cache = apin_in_cache; { @@ -1886,7 +1889,8 @@ Cache::open_write(Continuation *cont, const CacheKey *key, CacheHTTPInfo *info, return ACTION_RESULT_DONE; Lfailure: - CACHE_INCREMENT_DYN_STAT(c->base_stat + CACHE_STAT_FAILURE); + Metrics::increment(cache_rsb.status[c->op_type].failure); + Metrics::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/iocore/cache/P_Cache.h b/iocore/cache/P_Cache.h index 832d7d282c8..f6578705520 100644 --- a/iocore/cache/P_Cache.h +++ b/iocore/cache/P_Cache.h @@ -26,13 +26,13 @@ #include "tscore/ink_platform.h" #include "P_EventSystem.h" #include "P_AIO.h" -#include "records/I_RecProcess.h" #include "HTTP.h" #include "MIME.h" #include "HttpTransactCache.h" #include "I_Cache.h" +#include "P_CacheStats.h" #include "P_CacheDisk.h" #include "P_CacheDir.h" #include "P_RamCache.h" diff --git a/iocore/cache/P_CacheInternal.h b/iocore/cache/P_CacheInternal.h index e1fbbb8552a..8c6dba1abad 100644 --- a/iocore/cache/P_CacheInternal.h +++ b/iocore/cache/P_CacheInternal.h @@ -29,6 +29,9 @@ #include "HTTP.h" #include "P_CacheHttp.h" #include "P_CacheHosting.h" +#include "api/Metrics.h" + +using ts::Metrics; struct EvacuationBlock; @@ -96,117 +99,7 @@ struct EvacuationBlock; return EVENT_CONT; \ } while (0) -// cache stats definitions -enum { - cache_bytes_used_stat, - cache_bytes_total_stat, - cache_stripes_stat, - cache_ram_cache_bytes_stat, - cache_ram_cache_bytes_total_stat, - cache_direntries_total_stat, - cache_direntries_used_stat, - cache_ram_cache_hits_stat, - cache_ram_cache_misses_stat, - cache_pread_count_stat, - cache_percent_full_stat, - cache_lookup_active_stat, - cache_lookup_success_stat, - cache_lookup_failure_stat, - cache_read_active_stat, - cache_read_success_stat, - cache_read_failure_stat, - cache_read_seek_fail_stat, - cache_read_invalid_stat, - cache_write_active_stat, - cache_write_success_stat, - cache_write_failure_stat, - cache_write_backlog_failure_stat, - cache_update_active_stat, - cache_update_success_stat, - cache_update_failure_stat, - cache_remove_active_stat, - cache_remove_success_stat, - cache_remove_failure_stat, - cache_evacuate_active_stat, - cache_evacuate_success_stat, - cache_evacuate_failure_stat, - cache_scan_active_stat, - cache_scan_success_stat, - cache_scan_failure_stat, - cache_directory_collision_count_stat, - cache_single_fragment_document_count_stat, - cache_two_fragment_document_count_stat, - cache_three_plus_plus_fragment_document_count_stat, - cache_read_busy_success_stat, - cache_read_busy_failure_stat, - cache_gc_bytes_evacuated_stat, - cache_gc_frags_evacuated_stat, - cache_write_bytes_stat, - cache_hdr_vector_marshal_stat, - cache_hdr_marshal_stat, - cache_hdr_marshal_bytes_stat, - cache_directory_wrap_stat, - cache_directory_sync_count_stat, - cache_directory_sync_time_stat, - cache_directory_sync_bytes_stat, - /* AIO read/write error counters */ - cache_span_errors_read_stat, - cache_span_errors_write_stat, - /* Span related gauges. A span "moves" from "online" (errors==0) - * to "failing" (errors > 0 && errors < proxy.config.cache.max_disk_errors) - * to "offline"(errors >= proxy.config.cache.max_disk_errors. - * "failing" + "offline" + "online" = total number of spans */ - cache_span_offline_stat, - cache_span_online_stat, - cache_span_failing_stat, - cache_stat_count -}; - -extern RecRawStatBlock *cache_rsb; - -#define GLOBAL_CACHE_SET_DYN_STAT(x, y) RecSetGlobalRawStatSum(cache_rsb, (x), (y)) - -#define CACHE_SET_DYN_STAT(x, y) \ - RecSetGlobalRawStatSum(cache_rsb, (x), (y)) RecSetGlobalRawStatSum(vol->cache_vol->vol_rsb, (x), (y)) - -#define CACHE_INCREMENT_DYN_STAT(x) \ - do { \ - RecIncrRawStat(cache_rsb, mutex->thread_holding, (int)(x), 1); \ - RecIncrRawStat(vol->cache_vol->vol_rsb, mutex->thread_holding, (int)(x), 1); \ - } while (0); - -#define CACHE_DECREMENT_DYN_STAT(x) \ - do { \ - RecIncrRawStat(cache_rsb, mutex->thread_holding, (int)(x), -1); \ - RecIncrRawStat(vol->cache_vol->vol_rsb, mutex->thread_holding, (int)(x), -1); \ - } while (0); - -#define CACHE_VOL_SUM_DYN_STAT(x, y) RecIncrRawStat(vol->cache_vol->vol_rsb, mutex->thread_holding, (int)(x), (int64_t)y); - -#define CACHE_SUM_DYN_STAT(x, y) \ - do { \ - RecIncrRawStat(cache_rsb, mutex->thread_holding, (int)(x), (int64_t)(y)); \ - RecIncrRawStat(vol->cache_vol->vol_rsb, mutex->thread_holding, (int)(x), (int64_t)(y)); \ - } while (0); - -#define CACHE_SUM_DYN_STAT_THREAD(x, y) \ - do { \ - RecIncrRawStat(cache_rsb, this_ethread(), (int)(x), (int64_t)(y)); \ - RecIncrRawStat(vol->cache_vol->vol_rsb, this_ethread(), (int)(x), (int64_t)(y)); \ - } while (0); - -#define GLOBAL_CACHE_SUM_GLOBAL_DYN_STAT(x, y) RecIncrGlobalRawStatSum(cache_rsb, (x), (y)) - -#define CACHE_SUM_GLOBAL_DYN_STAT(x, y) \ - RecIncrGlobalRawStatSum(cache_rsb, (x), (y)) RecIncrGlobalRawStatSum(vol->cache_vol->vol_rsb, (x), (y)) - -#define CACHE_CLEAR_DYN_STAT(x) \ - do { \ - RecSetRawStatSum(cache_rsb, (x), 0); \ - RecSetRawStatCount(cache_rsb, (x), 0); \ - RecSetRawStatSum(vol->cache_vol->vol_rsb, (x), 0); \ - RecSetRawStatCount(vol->cache_vol->vol_rsb, (x), 0); \ - } while (0); +extern CacheStatsBlock cache_rsb; // Configuration extern int cache_config_dir_sync_frequency; @@ -402,11 +295,6 @@ struct CacheVC : public CacheVConnection { bool set_pin_in_cache(time_t time_pin) override; time_t get_pin_in_cache() override; -// offsets from the base stat -#define CACHE_STAT_ACTIVE 0 -#define CACHE_STAT_SUCCESS 1 -#define CACHE_STAT_FAILURE 2 - // number of bytes to memset to 0 in the CacheVC when we free // it. All member variables starting from vio are memset to 0. // This variable is initialized in CacheVC constructor. @@ -467,7 +355,7 @@ struct CacheVC : public CacheVConnection { ContinuationHandler save_handler; time_t pin_in_cache; ink_hrtime start_time; - int base_stat; + int op_type; // Index into the metrics array for this operation, rather than a CacheOpType (fewer casts) int recursive; int closed; uint64_t seek_to; // pread offset @@ -579,10 +467,13 @@ free_CacheVC(CacheVC *cont) Dbg(dbg_ctl, "free %p", cont); ProxyMutex *mutex = cont->mutex.get(); Vol *vol = cont->vol; + if (vol) { - CACHE_DECREMENT_DYN_STAT(cont->base_stat + CACHE_STAT_ACTIVE); + Metrics::decrement(cache_rsb.status[cont->op_type].active); + Metrics::decrement(vol->cache_vol->vol_rsb.status[cont->op_type].active); if (cont->closed > 0) { - CACHE_INCREMENT_DYN_STAT(cont->base_stat + CACHE_STAT_SUCCESS); + Metrics::increment(cache_rsb.status[cont->op_type].success); + Metrics::increment(vol->cache_vol->vol_rsb.status[cont->op_type].success); } // else abort,cancel } ink_assert(mutex->thread_holding == this_ethread()); @@ -786,10 +677,14 @@ Vol::open_write(CacheVC *cont, int allow_if_writers, int max_writers) agg_error = agg_error || ((uint32_t)mutex->thread_holding->generator.random() < (uint32_t)(UINT_MAX * CACHE_AGG_FAIL_RATE)); #endif } + if (agg_error) { - CACHE_INCREMENT_DYN_STAT(cache_write_backlog_failure_stat); + Metrics::increment(cache_rsb.write_backlog_failure); + Metrics::increment(vol->cache_vol->vol_rsb.write_backlog_failure); + return ECACHE_WRITE_FAIL; } + if (open_dir.open_write(cont, allow_if_writers, max_writers)) { #ifdef CACHE_STAT_PAGES ink_assert(cont->mutex->thread_holding == this_ethread()); @@ -956,17 +851,6 @@ CacheRemoveCont::event_handler(int event, void *data) return EVENT_DONE; } -int64_t cache_bytes_used(); -int64_t cache_bytes_total(); - -#ifdef DEBUG -#define CACHE_DEBUG_INCREMENT_DYN_STAT(_x) CACHE_INCREMENT_DYN_STAT(_x) -#define CACHE_DEBUG_SUM_DYN_STAT(_x, _y) CACHE_SUM_DYN_STAT(_x, _y) -#else -#define CACHE_DEBUG_INCREMENT_DYN_STAT(_x) -#define CACHE_DEBUG_SUM_DYN_STAT(_x, _y) -#endif - struct CacheHostRecord; struct Vol; class CacheHostTable; diff --git a/iocore/cache/P_CacheStats.h b/iocore/cache/P_CacheStats.h new file mode 100644 index 00000000000..b87b8f7dcf4 --- /dev/null +++ b/iocore/cache/P_CacheStats.h @@ -0,0 +1,70 @@ +/** @file + + A brief file description + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#pragma once + +// cache stats definitions, for both global cache metrics, as well as per volume metrics. +enum class CacheOpType { Lookup = 0, Read, Write, Update, Remove, Evacuate, Scan, Last }; + +struct CacheStatsBlock { + struct { + ts::Metrics::IntType *active; + ts::Metrics::IntType *success; + ts::Metrics::IntType *failure; + } status[static_cast(CacheOpType::Last)]; + + ts::Metrics::IntType *fragment_document_count[3]; // For 1, 2 and 3+ fragments + + ts::Metrics::IntType *bytes_used; + ts::Metrics::IntType *bytes_total; + ts::Metrics::IntType *stripes; + ts::Metrics::IntType *ram_cache_bytes; + ts::Metrics::IntType *ram_cache_bytes_total; + ts::Metrics::IntType *direntries_total; + ts::Metrics::IntType *direntries_used; + ts::Metrics::IntType *ram_cache_hits; + ts::Metrics::IntType *ram_cache_misses; + ts::Metrics::IntType *pread_count; + ts::Metrics::IntType *percent_full; + ts::Metrics::IntType *read_seek_fail; + ts::Metrics::IntType *read_invalid; + ts::Metrics::IntType *write_backlog_failure; + ts::Metrics::IntType *directory_collision_count; + ts::Metrics::IntType *read_busy_success; + ts::Metrics::IntType *read_busy_failure; + ts::Metrics::IntType *gc_bytes_evacuated; + ts::Metrics::IntType *gc_frags_evacuated; + ts::Metrics::IntType *write_bytes; + ts::Metrics::IntType *hdr_vector_marshal; + ts::Metrics::IntType *hdr_marshal; + ts::Metrics::IntType *hdr_marshal_bytes; + ts::Metrics::IntType *directory_wrap; + ts::Metrics::IntType *directory_sync_count; + ts::Metrics::IntType *directory_sync_time; + ts::Metrics::IntType *directory_sync_bytes; + ts::Metrics::IntType *span_errors_read; + ts::Metrics::IntType *span_errors_write; + ts::Metrics::IntType *span_offline; + ts::Metrics::IntType *span_online; + ts::Metrics::IntType *span_failing; +}; diff --git a/iocore/cache/P_CacheVol.h b/iocore/cache/P_CacheVol.h index 9c9e99592a6..37c7ea36e93 100644 --- a/iocore/cache/P_CacheVol.h +++ b/iocore/cache/P_CacheVol.h @@ -27,6 +27,8 @@ #include "tscore/CryptoHash.h" +#include "P_Cache.h" + #define CACHE_BLOCK_SHIFT 9 #define CACHE_BLOCK_SIZE (1 << CACHE_BLOCK_SHIFT) // 512, smallest sector size #define ROUND_TO_STORE_BLOCK(_x) INK_ALIGN((_x), STORE_BLOCK_SIZE) @@ -272,7 +274,7 @@ struct CacheVol { DiskVol **disk_vols = nullptr; LINK(CacheVol, link); // per volume stats - RecRawStatBlock *vol_rsb = nullptr; + CacheStatsBlock vol_rsb; CacheVol() {} }; diff --git a/iocore/cache/RamCacheCLFUS.cc b/iocore/cache/RamCacheCLFUS.cc index 9439597f4be..1e8e8424b48 100644 --- a/iocore/cache/RamCacheCLFUS.cc +++ b/iocore/cache/RamCacheCLFUS.cc @@ -301,7 +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; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, delta); + Metrics::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->compressed_len; check_accounting(this); e->flag_bits.compressed = 0; @@ -316,11 +317,13 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey } (*ret_data) = data; } - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_hits_stat, 1); + Metrics::increment(cache_rsb.ram_cache_hits); + Metrics::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 { - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_misses_stat, 1); + Metrics::increment(cache_rsb.ram_cache_misses); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_misses); DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " HISTORY", key->slice32(3), auxkey); return 0; } @@ -330,7 +333,9 @@ RamCacheCLFUS::get(CryptoHash *key, Ptr *ret_data, uint64_t auxkey } DDbg(dbg_ctl_ram_cache, "get %X %" PRId64 " MISS", key->slice32(3), auxkey); Lerror: - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_misses_stat, 1); + Metrics::increment(cache_rsb.ram_cache_misses); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + return 0; Lfailed: ats_free(b); @@ -402,7 +407,8 @@ RamCacheCLFUS::_destroy(RamCacheCLFUSEntry *e) if (!e->flag_bits.lru) { this->_objects--; this->_bytes -= e->size + ENTRY_OVERHEAD; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, -(int64_t)e->size); + Metrics::decrement(cache_rsb.ram_cache_bytes, e->size); + Metrics::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, e->size); e->data = nullptr; } else { this->_history--; @@ -530,7 +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; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, delta); + Metrics::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = l; } else { ats_free(b); @@ -539,7 +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; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, delta); + Metrics::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); e->size = e->len; l = e->len; } @@ -570,7 +578,8 @@ RamCacheCLFUS::_requeue_victims(Que(RamCacheCLFUSEntry, lru_link) & victims) RamCacheCLFUSEntry *victim = nullptr; while ((victim = victims.dequeue())) { this->_bytes += victim->size + ENTRY_OVERHEAD; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, victim->size); + Metrics::increment(cache_rsb.ram_cache_bytes, victim->size); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } @@ -605,7 +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; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, delta); + Metrics::increment(cache_rsb.ram_cache_bytes, delta); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, delta); if (!copy) { e->size = size; e->data = data; @@ -666,7 +676,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, continue; } this->_bytes -= victim->size + ENTRY_OVERHEAD; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, -(int64_t)victim->size); + Metrics::decrement(cache_rsb.ram_cache_bytes, victim->size); + Metrics::decrement(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victims.enqueue(victim); if (victim == this->_compressed) { this->_compressed = nullptr; @@ -694,7 +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; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, victim->size); + Metrics::increment(cache_rsb.ram_cache_bytes, victim->size); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, victim->size); victim->hits = REQUEUE_HITS(victim->hits); this->_lru[0].enqueue(victim); } else { @@ -726,7 +738,8 @@ RamCacheCLFUS::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool copy, } e->flag_bits.copy = copy; this->_bytes += size + ENTRY_OVERHEAD; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, size); + Metrics::increment(cache_rsb.ram_cache_bytes, size); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_bytes, size); e->size = size; this->_objects++; this->_lru[0].enqueue(e); diff --git a/iocore/cache/RamCacheLRU.cc b/iocore/cache/RamCacheLRU.cc index f62da888e98..912c1e340a6 100644 --- a/iocore/cache/RamCacheLRU.cc +++ b/iocore/cache/RamCacheLRU.cc @@ -141,13 +141,17 @@ 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); - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_hits_stat, 1); + Metrics::increment(cache_rsb.ram_cache_hits); + Metrics::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); - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_misses_stat, 1); + Metrics::increment(cache_rsb.ram_cache_misses); + Metrics::increment(vol->cache_vol->vol_rsb.ram_cache_misses); + return 0; } @@ -159,7 +163,9 @@ RamCacheLRU::remove(RamCacheLRUEntry *e) bucket[b].remove(e); lru.remove(e); bytes -= ENTRY_OVERHEAD + e->data->block_size(); - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, -(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()); + DDbg(dbg_ctl_ram_cache, "put %X %" PRIu64 " FREED", e->key.slice32(3), e->auxkey); e->data = nullptr; THREAD_FREE(e, ramCacheLRUEntryAllocator, this_thread()); @@ -206,7 +212,8 @@ RamCacheLRU::put(CryptoHash *key, IOBufferData *data, uint32_t len, bool, uint64 lru.enqueue(e); bytes += ENTRY_OVERHEAD + data->block_size(); objects++; - CACHE_SUM_DYN_STAT_THREAD(cache_ram_cache_bytes_stat, ENTRY_OVERHEAD + data->block_size()); + 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()); while (bytes > max_bytes) { RamCacheLRUEntry *ee = lru.dequeue(); if (ee) { diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc index fb710acb9ed..c2b21828304 100644 --- a/iocore/dns/DNS.cc +++ b/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) { - DNS_INCREMENT_DYN_STAT(dns_tcp_reset_stat); + Metrics::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; - DNS_DECREMENT_DYN_STAT(dns_in_flight_stat); + Metrics::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; - DNS_DECREMENT_DYN_STAT(dns_in_flight_stat); + Metrics::decrement(dns_rsb.in_flight); } } } @@ -1079,8 +1079,7 @@ get_entry(DNSHandler *h, char *qname, int qtype) static void write_dns(DNSHandler *h, bool tcp_retry) { - ProxyMutex *mutex = h->mutex.get(); - DNS_INCREMENT_DYN_STAT(dns_total_lookups_stat); + Metrics::increment(dns_rsb.total_lookups); int max_nscount = h->m_res->nscount; if (max_nscount > MAX_NAMED) { max_nscount = MAX_NAMED; @@ -1164,7 +1163,6 @@ DNSHandler::get_query_id() static bool write_dns_event(DNSHandler *h, DNSEntry *e, bool over_tcp) { - ProxyMutex *mutex = h->mutex.get(); unsigned char buffer[MAX_DNS_REQUEST_LEN]; int offset = over_tcp ? tcp_data_length_offset : 0; HEADER *header = reinterpret_cast
(buffer + offset); @@ -1219,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; - DNS_INCREMENT_DYN_STAT(dns_in_flight_stat); + Metrics::increment(dns_rsb.in_flight); e->send_time = ink_get_hrtime(); @@ -1304,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); - DNS_DECREMENT_DYN_STAT(dns_in_flight_stat); + Metrics::decrement(dns_rsb.in_flight); } timeout = nullptr; dns_result(dnsH, this, result_ent.get(), true); @@ -1343,16 +1341,15 @@ DNSProcessor::getby(DNSQueryData x, int type, Continuation *cont, Options const static void dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) { - ProxyMutex *mutex = h->mutex.get(); - bool cancelled = (e->action.cancelled ? true : false); - retry = retry || tcp_retry; + bool cancelled = (e->action.cancelled ? true : false); + retry = retry || tcp_retry; if ((!ent || !ent->good) && !cancelled) { // try to retry operation if (retry && e->retries) { Dbg(dbg_ctl_dns, "doing retry for %s", e->qname); - DNS_INCREMENT_DYN_STAT(dns_retries_stat); + Metrics::increment(dns_rsb.tcp_retries); --(e->retries); write_dns(h, tcp_retry); @@ -1388,17 +1385,24 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) } } if (retry) { - DNS_INCREMENT_DYN_STAT(dns_max_retries_exceeded_stat); + Metrics::increment(dns_rsb.max_retries_exceeded); } } if (ent == BAD_DNS_RESULT) { ent = nullptr; } if (!cancelled) { + // ToDo: Should this possibly be send_time() ?? + ink_hrtime diff = (ink_get_hrtime() - e->submit_time) / HRTIME_MSECOND; + + // These are rolling averages, this requires that the lookup_fail/success counters are incremented later if (!ent || !ent->good) { - DNS_SUM_DYN_STAT(dns_fail_time_stat, ink_get_hrtime() - e->submit_time); + Metrics::increment(dns_rsb.fail_time, diff); + Metrics::increment(dns_rsb.lookup_fail); } else { - DNS_SUM_DYN_STAT(dns_success_time_stat, ink_get_hrtime() - e->submit_time); + Metrics::increment(dns_rsb.success_time, diff); + + Metrics::increment(dns_rsb.lookup_success); } } @@ -1431,12 +1435,6 @@ dns_result(DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry, bool tcp_retry) } } - if (ent && ent->good) { - DNS_INCREMENT_DYN_STAT(dns_lookup_success_stat); - } else { - DNS_INCREMENT_DYN_STAT(dns_lookup_fail_stat); - } - // Save HostEnt to the head node e->result_ent = ent; e->retries = 0; @@ -1524,7 +1522,6 @@ DNSEntry::postOneEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */) static bool dns_process(DNSHandler *handler, HostEnt *buf, int len) { - ProxyMutex *mutex = handler->mutex.get(); HEADER *h = reinterpret_cast
(buf->buf); DNSEntry *e = get_dns(handler, static_cast(ntohs(h->id))); bool retry = false; @@ -1562,15 +1559,17 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len) // e->written_flag = false; --(handler->in_flight); - DNS_DECREMENT_DYN_STAT(dns_in_flight_stat); + Metrics::decrement(dns_rsb.in_flight); + // These are rolling averages + ink_hrtime diff = (ink_get_hrtime() - e->send_time) / HRTIME_MSECOND; - DNS_SUM_DYN_STAT(dns_response_time_stat, ink_get_hrtime() - e->send_time); + Metrics::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; - DNS_INCREMENT_DYN_STAT(dns_tcp_retries_stat); + Metrics::increment(dns_rsb.tcp_retries); goto Lerror; } @@ -1883,13 +1882,13 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len) } } Lerror:; - DNS_INCREMENT_DYN_STAT(dns_lookup_fail_stat); + Metrics::increment(dns_rsb.lookup_fail); buf->good = false; dns_result(handler, e, buf, retry, tcp_retry); return server_ok; } -RecRawStatBlock *dns_rsb; +DNSStatsBlock dns_rsb; void ink_dns_init(ts::ModuleVersion v) @@ -1904,45 +1903,23 @@ ink_dns_init(ts::ModuleVersion v) } init_called = 1; - // do one time stuff - // create a stat block for HostDBStats - dns_rsb = RecAllocateRawStatBlock(static_cast(DNS_Stat_Count)); // // Register statistics callbacks // - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.total_dns_lookups", RECD_INT, RECP_PERSISTENT, - (int)dns_total_lookups_stat, RecRawStatSyncSum); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.lookup_avg_time", RECD_INT, RECP_PERSISTENT, - (int)dns_response_time_stat, RecRawStatSyncHrTimeAvg); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.success_avg_time", RECD_INT, RECP_NON_PERSISTENT, - (int)dns_success_time_stat, RecRawStatSyncHrTimeAvg); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.lookup_successes", RECD_INT, RECP_PERSISTENT, - (int)dns_lookup_success_stat, RecRawStatSyncSum); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.fail_avg_time", RECD_INT, RECP_PERSISTENT, (int)dns_fail_time_stat, - RecRawStatSyncHrTimeAvg); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.lookup_failures", RECD_INT, RECP_PERSISTENT, - (int)dns_lookup_fail_stat, RecRawStatSyncSum); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.retries", RECD_INT, RECP_PERSISTENT, (int)dns_retries_stat, - RecRawStatSyncSum); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.max_retries_exceeded", RECD_INT, RECP_PERSISTENT, - (int)dns_max_retries_exceeded_stat, RecRawStatSyncSum); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.in_flight", RECD_INT, RECP_NON_PERSISTENT, (int)dns_in_flight_stat, - RecRawStatSyncSum); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.tcp_retries", RECD_INT, RECP_PERSISTENT, (int)dns_tcp_retries_stat, - RecRawStatSyncSum); - - RecRegisterRawStat(dns_rsb, RECT_PROCESS, "proxy.process.dns.tcp_reset", RECD_INT, RECP_PERSISTENT, (int)dns_tcp_reset_stat, - RecRawStatSyncSum); + 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"); } #if TS_HAS_TESTS diff --git a/iocore/dns/P_DNSProcessor.h b/iocore/dns/P_DNSProcessor.h index 12976842f38..25e10cb05a9 100644 --- a/iocore/dns/P_DNSProcessor.h +++ b/iocore/dns/P_DNSProcessor.h @@ -25,6 +25,9 @@ #include "I_EventSystem.h" #include "tscore/PendingAction.h" +#include "api/Metrics.h" + +using ts::Metrics; #define MAX_NAMED 32 #define DEFAULT_DNS_RETRIES 5 @@ -75,33 +78,24 @@ extern unsigned int dns_sequence_number; #endif // Stats -enum DNS_Stats { - dns_total_lookups_stat, - dns_response_time_stat, - dns_success_time_stat, - dns_lookup_success_stat, - dns_lookup_fail_stat, - dns_fail_time_stat, - dns_retries_stat, - dns_max_retries_exceeded_stat, - dns_in_flight_stat, - dns_tcp_retries_stat, - dns_tcp_reset_stat, - DNS_Stat_Count +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; }; struct HostEnt; struct DNSHandler; -struct RecRawStatBlock; -extern RecRawStatBlock *dns_rsb; - -// Stat Macros -#define DNS_INCREMENT_DYN_STAT(_x) RecIncrRawStatSum(dns_rsb, mutex->thread_holding, (int)_x, 1) - -#define DNS_DECREMENT_DYN_STAT(_x) RecIncrRawStatSum(dns_rsb, mutex->thread_holding, (int)_x, -1) - -#define DNS_SUM_DYN_STAT(_x, _r) RecIncrRawStatSum(dns_rsb, mutex->thread_holding, (int)_x, _r) +extern DNSStatsBlock dns_rsb; /** One DNSEntry is allocated per outstanding request. This continuation diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index 8dca07a3c62..d2a03d6eeee 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -593,7 +593,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()) { - HOSTDB_INCREMENT_DYN_STAT_THREAD(hostdb_ttl_expires_stat, this_ethread()); + Metrics::increment(hostdb_rsb.ttl_expires); return NO_RECORD; } } @@ -601,7 +601,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())) { - HOSTDB_INCREMENT_DYN_STAT_THREAD(hostdb_total_serve_stale_stat, this_ethread()); + Metrics::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(), @@ -639,11 +639,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) { - HOSTDB_INCREMENT_DYN_STAT(hostdb_re_dns_on_reload_stat); + Metrics::increment(hostdb_rsb.re_dns_on_reload); } } - HOSTDB_INCREMENT_DYN_STAT(hostdb_total_lookups_stat); + Metrics::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 @@ -687,7 +687,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) : ""); } - HOSTDB_INCREMENT_DYN_STAT(hostdb_total_hits_stat); + Metrics::increment(hostdb_rsb.total_hits); if (cb_process_result) { (cont->*cb_process_result)(r.get()); } else { @@ -830,10 +830,9 @@ Action * HostDBProcessor::iterate(Continuation *cont) { ink_assert(cont->mutex->thread_holding == this_ethread()); - EThread *thread = cont->mutex->thread_holding; - ProxyMutex *mutex = thread->mutex.get(); + EThread *thread = cont->mutex->thread_holding; - HOSTDB_INCREMENT_DYN_STAT(hostdb_total_lookups_stat); + Metrics::increment(hostdb_rsb.total_lookups); HostDBContinuation *c = hostDBContAllocator.alloc(); HostDBContinuation::Options copt; @@ -898,7 +897,7 @@ HostDBContinuation::lookup_done(TextView query_name, ts_seconds answer_ttl, SRVH } break; } - HOSTDB_SUM_DYN_STAT(hostdb_ttl_stat, answer_ttl.count()); + Metrics::increment(hostdb_rsb.ttl, answer_ttl.count()); // update the TTL record->ip_timestamp = hostdb_current_timestamp; @@ -1268,7 +1267,7 @@ HostDBContinuation::probeEvent(int /* event ATS_UNUSED */, Event *e) Ptr r = probe(hash, false); if (r) { - HOSTDB_INCREMENT_DYN_STAT(hostdb_total_hits_stat); + Metrics::increment(hostdb_rsb.total_hits); } if (action.continuation && r) { @@ -1296,7 +1295,7 @@ HostDBContinuation::set_check_pending_dns() Queue &q = hostDB.pending_dns_for_hash(hash.hash); this->setThreadAffinity(this_ethread()); if (q.in(this)) { - HOSTDB_INCREMENT_DYN_STAT(hostdb_insert_duplicate_to_pending_dns_stat); + Metrics::increment(hostdb_rsb.insert_duplicate_to_pending_dns); Dbg(dbg_ctl_hostdb, "Skip the insertion of the same continuation to pending dns"); return false; } @@ -1857,7 +1856,7 @@ REGRESSION_TEST(HostDBTests)(RegressionTest *t, int atype, int *pstatus) } #endif -RecRawStatBlock *hostdb_rsb; +HostDBStatsBlock hostdb_rsb; void ink_hostdb_init(ts::ModuleVersion v) @@ -1870,34 +1869,19 @@ ink_hostdb_init(ts::ModuleVersion v) } init_called = 1; - // do one time stuff - // create a stat block for HostDBStats - hostdb_rsb = RecAllocateRawStatBlock(static_cast(HostDB_Stat_Count)); // // Register stats // - - RecRegisterRawStat(hostdb_rsb, RECT_PROCESS, "proxy.process.hostdb.total_lookups", RECD_INT, RECP_PERSISTENT, - (int)hostdb_total_lookups_stat, RecRawStatSyncSum); - - RecRegisterRawStat(hostdb_rsb, RECT_PROCESS, "proxy.process.hostdb.total_hits", RECD_INT, RECP_PERSISTENT, - (int)hostdb_total_hits_stat, RecRawStatSyncSum); - - RecRegisterRawStat(hostdb_rsb, RECT_PROCESS, "proxy.process.hostdb.total_serve_stale", RECD_INT, RECP_PERSISTENT, - (int)hostdb_total_serve_stale_stat, RecRawStatSyncSum); - - RecRegisterRawStat(hostdb_rsb, RECT_PROCESS, "proxy.process.hostdb.ttl", RECD_FLOAT, RECP_PERSISTENT, (int)hostdb_ttl_stat, - RecRawStatSyncAvg); - - RecRegisterRawStat(hostdb_rsb, RECT_PROCESS, "proxy.process.hostdb.ttl_expires", RECD_INT, RECP_PERSISTENT, - (int)hostdb_ttl_expires_stat, RecRawStatSyncSum); - - RecRegisterRawStat(hostdb_rsb, RECT_PROCESS, "proxy.process.hostdb.re_dns_on_reload", RECD_INT, RECP_PERSISTENT, - (int)hostdb_re_dns_on_reload_stat, RecRawStatSyncSum); - - RecRegisterRawStat(hostdb_rsb, RECT_PROCESS, "proxy.process.hostdb.insert_duplicate_to_pending_dns", RECD_INT, RECP_PERSISTENT, - (int)hostdb_insert_duplicate_to_pending_dns_stat, RecRawStatSyncSum); + ts::Metrics &intm = ts::Metrics::getInstance(); + + hostdb_rsb.total_lookups = intm.newMetricPtr("proxy.process.hostdb.total_lookups"); + hostdb_rsb.total_hits = intm.newMetricPtr("proxy.process.hostdb.total_hits"); + hostdb_rsb.total_serve_stale = intm.newMetricPtr("proxy.process.hostdb.total_serve_stale"); + hostdb_rsb.ttl = intm.newMetricPtr("proxy.process.hostdb.ttl"); + hostdb_rsb.ttl_expires = intm.newMetricPtr("proxy.process.hostdb.ttl_expires"); + hostdb_rsb.re_dns_on_reload = intm.newMetricPtr("proxy.process.hostdb.re_dns_on_reload"); + hostdb_rsb.insert_duplicate_to_pending_dns = intm.newMetricPtr("proxy.process.hostdb.insert_duplicate_to_pending_dns"); ts_host_res_global_init(); } diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h index 29e31bc3f7f..304a7b571b8 100644 --- a/iocore/hostdb/P_HostDBProcessor.h +++ b/iocore/hostdb/P_HostDBProcessor.h @@ -35,6 +35,9 @@ #include "I_HostDBProcessor.h" #include "P_RefCountCache.h" #include "tscore/PendingAction.h" +#include "api/Metrics.h" + +using ts::Metrics; // // Data @@ -116,43 +119,17 @@ const unsigned int HOST_DB_MAX_TTL = (0x1FFFFF); // 24 days struct HostEnt; // Stats -enum HostDB_Stats { - hostdb_total_lookups_stat, - hostdb_total_hits_stat, // D == total hits - hostdb_total_serve_stale_stat, // D == total times we served a stale response - hostdb_ttl_stat, // D average TTL - hostdb_ttl_expires_stat, // D == TTL Expires - hostdb_re_dns_on_reload_stat, - hostdb_insert_duplicate_to_pending_dns_stat, - HostDB_Stat_Count +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; }; -struct RecRawStatBlock; -extern RecRawStatBlock *hostdb_rsb; - -// Stat Macros - -#define HOSTDB_DEBUG_COUNT_DYN_STAT(_x, _y) RecIncrRawStatCount(hostdb_rsb, mutex->thread_holding, (int)_x, _y) - -#define HOSTDB_INCREMENT_DYN_STAT(_x) RecIncrRawStatSum(hostdb_rsb, mutex->thread_holding, (int)_x, 1) - -#define HOSTDB_INCREMENT_DYN_STAT_THREAD(_x, _t) RecIncrRawStatSum(hostdb_rsb, _t, (int)_x, 1) - -#define HOSTDB_DECREMENT_DYN_STAT(_x) RecIncrRawStatSum(hostdb_rsb, mutex->thread_holding, (int)_x, -1) - -#define HOSTDB_SUM_DYN_STAT(_x, _r) RecIncrRawStatSum(hostdb_rsb, mutex->thread_holding, (int)_x, _r) - -#define HOSTDB_READ_DYN_STAT(_x, _count, _sum) \ - do { \ - RecGetRawStatSum(hostdb_rsb, (int)_x, &_sum); \ - RecGetRawStatCount(hostdb_rsb, (int)_x, &_count); \ - } while (0) - -#define HOSTDB_SET_DYN_COUNT(_x, _count) RecSetRawStatCount(hostdb_rsb, _x, _count); - -#define HOSTDB_INCREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStatSum(hostdb_rsb, _t, (int)_s, 1); - -#define HOSTDB_DECREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStatSum(hostdb_rsb, _t, (int)_s, -1); +extern HostDBStatsBlock hostdb_rsb; struct HostFile; diff --git a/iocore/hostdb/P_RefCountCache.h b/iocore/hostdb/P_RefCountCache.h index 120bb2b88f4..67bf89f8bb9 100644 --- a/iocore/hostdb/P_RefCountCache.h +++ b/iocore/hostdb/P_RefCountCache.h @@ -34,9 +34,13 @@ #include "tscore/I_Version.h" #include "tscpp/util/TsSharedMutex.h" + +#include "api/Metrics.h" #include #include +using ts::Metrics; + #define REFCOUNT_CACHE_EVENT_SYNC REFCOUNT_CACHE_EVENT_EVENTS_START #define REFCOUNTCACHE_MAGIC_NUMBER 0x0BAD2D9 @@ -46,20 +50,16 @@ static constexpr unsigned char REFCOUNTCACHE_MINOR_VERSION = 0; static constexpr ts::VersionNumber REFCOUNTCACHE_VERSION(1, 0); // Stats -enum RefCountCache_Stats { - refcountcache_current_items_stat, // current number of items - refcountcache_current_size_stat, // current size of cache - refcountcache_total_inserts_stat, // total items inserted - refcountcache_total_failed_inserts_stat, // total items unable to insert - refcountcache_total_lookups_stat, // total get() calls - refcountcache_total_hits_stat, // total hits - - // Persistence metrics - refcountcache_last_sync_time, // seconds since epoch of last successful sync - refcountcache_last_total_items, // number of items sync last time - refcountcache_last_total_size, // total size at last sync - - RefCountCache_Stat_Count +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; }; struct RefCountCacheItemMeta { @@ -163,7 +163,7 @@ template class RefCountCachePartition : private RefCountCacheBase public: using hash_type = swoc::IntrusiveHashMap; - RefCountCachePartition(unsigned int part_num, uint64_t max_size, unsigned int max_items, RecRawStatBlock *rsb = nullptr); + RefCountCachePartition(unsigned int part_num, uint64_t max_size, unsigned int max_items, RefCountCacheBlock *rsb = nullptr); Ptr get(uint64_t key); void put(uint64_t key, C *item, int size = 0, int expire_time = 0); void erase(uint64_t key, ink_time_t expiry_time = -1); @@ -181,8 +181,6 @@ template class RefCountCachePartition : private RefCountCacheBase ts::shared_mutex lock; private: - void metric_inc(RefCountCache_Stats metric_enum, int64_t data); - unsigned int part_num; uint64_t max_size; unsigned int max_items; @@ -192,12 +190,12 @@ template class RefCountCachePartition : private RefCountCacheBase hash_type item_map; PriorityQueue expiry_queue; - RecRawStatBlock *rsb; + RefCountCacheBlock *rsb; }; template RefCountCachePartition::RefCountCachePartition(unsigned int part_num, uint64_t max_size, unsigned int max_items, - RecRawStatBlock *rsb) + RefCountCacheBlock *rsb) : part_num(part_num), max_size(max_size), max_items(max_items), size(0), items(0), rsb(rsb) { } @@ -206,10 +204,10 @@ template Ptr RefCountCachePartition::get(uint64_t key) { - this->metric_inc(refcountcache_total_lookups_stat, 1); + Metrics::increment(this->rsb->refcountcache_total_lookups); if (auto it = this->item_map.find(key); it != this->item_map.end()) { // found - this->metric_inc(refcountcache_total_hits_stat, 1); + Metrics::increment(this->rsb->refcountcache_total_hits); return make_ptr(static_cast(it->item.get())); } else { return Ptr(); @@ -220,7 +218,7 @@ template void RefCountCachePartition::put(uint64_t key, C *item, int size, int expire_time) { - this->metric_inc(refcountcache_total_inserts_stat, 1); + Metrics::increment(this->rsb->refcountcache_total_inserts); size += sizeof(C); // Remove any colliding entries this->erase(key); @@ -228,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); - this->metric_inc(refcountcache_total_failed_inserts_stat, 1); + Metrics::increment(this->rsb->refcountcache_total_failed_inserts); return; } @@ -249,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++; - this->metric_inc(refcountcache_current_size_stat, (int64_t)val->meta.size); - this->metric_inc(refcountcache_current_items_stat, 1); + Metrics::increment(this->rsb->refcountcache_current_size, (int64_t)val->meta.size); + Metrics::increment(this->rsb->refcountcache_current_items); } template @@ -275,8 +273,8 @@ RefCountCachePartition::dealloc_entry(hash_type::iterator ptr) this->size -= ptr->meta.size; this->items--; - this->metric_inc(refcountcache_current_size_stat, -((int64_t)ptr->meta.size)); - this->metric_inc(refcountcache_current_items_stat, -1); + Metrics::decrement(this->rsb->refcountcache_current_size, ptr->meta.size); + Metrics::decrement(this->rsb->refcountcache_current_items); // remove from expiry queue if (ptr->expiry_entry != nullptr) { @@ -357,15 +355,6 @@ RefCountCachePartition::copy(std::vector &items) } } -template -void -RefCountCachePartition::metric_inc(RefCountCache_Stats metric_enum, int64_t data) -{ - if (this->rsb) { - RecIncrGlobalRawStatCount(this->rsb, metric_enum, data); - } -} - template swoc::IntrusiveHashMap & RefCountCachePartition::get_map() @@ -405,7 +394,7 @@ template class RefCountCache public: // Constructor RefCountCache(unsigned int num_partitions, int size = -1, int items = -1, ts::VersionNumber object_version = ts::VersionNumber(), - const std::string &metrics_prefix = ""); + const std::string metrics_prefix = ".refcountcache"); // Destructor ~RefCountCache(); @@ -422,7 +411,7 @@ template class RefCountCache RefCountCachePartition &get_partition(int pnum); size_t count() const; RefCountCacheHeader &get_header(); - RecRawStatBlock *get_rsb(); + RefCountCacheBlock *get_rsb(); private: int max_size; // Total size @@ -431,52 +420,34 @@ template class RefCountCache std::vector *> partitions; // Header RefCountCacheHeader header; // Our header - RecRawStatBlock *rsb; + RefCountCacheBlock rsb; }; template RefCountCache::RefCountCache(unsigned int num_partitions, int size, int items, ts::VersionNumber object_version, - const std::string &metrics_prefix) - : header(RefCountCacheHeader(object_version)), rsb(nullptr) + 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; - if (metrics_prefix.length() > 0) { - this->rsb = RecAllocateRawStatBlock((int)RefCountCache_Stat_Count); + 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()); - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "current_items").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_current_items_stat, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "current_size").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_current_size_stat, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "total_inserts").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_total_inserts_stat, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "total_failed_inserts").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_total_failed_inserts_stat, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "total_lookups").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_total_lookups_stat, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "total_hits").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_total_hits_stat, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "last_sync.time").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_last_sync_time, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "last_sync.total_items").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_last_total_items, RecRawStatSyncCount); - - RecRegisterRawStat(this->rsb, RECT_PROCESS, (metrics_prefix + "last_sync.total_size").c_str(), RECD_INT, RECP_NON_PERSISTENT, - (int)refcountcache_last_total_size, RecRawStatSyncCount); - } // Now lets create all the partitions this->partitions.reserve(num_partitions); for (unsigned int i = 0; i < num_partitions; i++) { - this->partitions.push_back(new RefCountCachePartition(i, size / num_partitions, items / num_partitions, this->rsb)); + this->partitions.push_back(new RefCountCachePartition(i, size / num_partitions, items / num_partitions, &this->rsb)); } } @@ -551,10 +522,10 @@ RefCountCache::partition_count() const } template -RecRawStatBlock * +RefCountCacheBlock * RefCountCache::get_rsb() { - return this->rsb; + return &this->rsb; } template diff --git a/iocore/io_uring/I_IO_URING.h b/iocore/io_uring/I_IO_URING.h index b83df7974c0..3192600f4cc 100644 --- a/iocore/io_uring/I_IO_URING.h +++ b/iocore/io_uring/I_IO_URING.h @@ -90,6 +90,3 @@ class IOUringContext void handle_cqe(io_uring_cqe *); static IOUringConfig config; }; - -extern std::atomic io_uring_submissions; -extern std::atomic io_uring_completions; diff --git a/iocore/io_uring/io_uring.cc b/iocore/io_uring/io_uring.cc index 81523f4dc36..0598a095ba2 100644 --- a/iocore/io_uring/io_uring.cc +++ b/iocore/io_uring/io_uring.cc @@ -33,8 +33,6 @@ Linux io_uring helper library #include "tscore/Diags.h" std::atomic main_wq_fd; -std::atomic io_uring_submissions = 0; -std::atomic io_uring_completions = 0; IOUringConfig IOUringContext::config; @@ -130,7 +128,7 @@ IOUringContext::get_wq_max_workers() void IOUringContext::submit() { - io_uring_submissions.fetch_add(io_uring_submit(&ring)); + Metrics::increment(aio_rsb.io_uring_submitted, io_uring_submit(&ring)); } void @@ -148,7 +146,7 @@ IOUringContext::service() io_uring_peek_cqe(&ring, &cqe); while (cqe) { handle_cqe(cqe); - io_uring_completions++; + Metrics::increment(aio_rsb.io_uring_completed); io_uring_cqe_seen(&ring, cqe); cqe = nullptr; @@ -169,10 +167,11 @@ IOUringContext::submit_and_wait(ink_hrtime t) io_uring_cqe *cqe = nullptr; int count = io_uring_submit_and_wait_timeout(&ring, &cqe, 1, &timeout, nullptr); - io_uring_submissions.fetch_add(count); + + Metrics::increment(aio_rsb.io_uring_submitted, count); while (cqe) { handle_cqe(cqe); - io_uring_completions++; + Metrics::increment(aio_rsb.io_uring_completed); io_uring_cqe_seen(&ring, cqe); cqe = nullptr; diff --git a/iocore/io_uring/unit_tests/test_diskIO.cc b/iocore/io_uring/unit_tests/test_diskIO.cc index 36f39282f50..99967a2149b 100644 --- a/iocore/io_uring/unit_tests/test_diskIO.cc +++ b/iocore/io_uring/unit_tests/test_diskIO.cc @@ -262,9 +262,10 @@ TEST_CASE("net_io", "[io_uring]") connected = true; }); - uint64_t completions_before = io_uring_completions; + uint64_t completions_before = Metrics::read(aio_rsb.io_uring_completed); uint64_t needed = 2; - while ((io_uring_completions - completions_before) < needed) { + + while ((Metrics::read(aio_rsb.io_uring_completed) - completions_before) < needed) { ctx.submit_and_wait(1 * HRTIME_SECOND); } diff --git a/iocore/net/BIO_fastopen.cc b/iocore/net/BIO_fastopen.cc index 48e5abbe3fb..d6774639f4e 100644 --- a/iocore/net/BIO_fastopen.cc +++ b/iocore/net/BIO_fastopen.cc @@ -119,13 +119,11 @@ fastopen_bwrite(BIO *bio, const char *in, int insz) // RFC 7413. If we get EINPROGRESS it means that the SYN has been // sent without data and we should retry. const sockaddr *dst = reinterpret_cast(BIO_get_data(bio)); - ProxyMutex *mutex = this_ethread()->mutex.get(); - - NET_INCREMENT_DYN_STAT(net_fastopen_attempts_stat); + Metrics::increment(net_rsb.fastopen_attempts); err = SocketManager::sendto(fd, (void *)in, insz, MSG_FASTOPEN, dst, ats_ip_size(dst)); if (err >= 0) { - NET_INCREMENT_DYN_STAT(net_fastopen_successes_stat); + Metrics::increment(net_rsb.fastopen_successes); } BIO_set_data(bio, nullptr); diff --git a/iocore/net/Net.cc b/iocore/net/Net.cc index e8f9316cc40..0550566e5c4 100644 --- a/iocore/net/Net.cc +++ b/iocore/net/Net.cc @@ -31,7 +31,7 @@ #include "P_Net.h" #include -RecRawStatBlock *net_rsb = nullptr; +NetStatsBlock net_rsb; // All in milli-seconds int net_event_period = 10; @@ -79,66 +79,35 @@ configure_net() static inline void register_net_stats() { - const std::pair persistent[] = { - {"proxy.process.net.calls_to_read", net_calls_to_read_stat }, - {"proxy.process.net.calls_to_read_nodata", net_calls_to_read_nodata_stat }, - {"proxy.process.net.calls_to_readfromnet", net_calls_to_readfromnet_stat }, - {"proxy.process.net.calls_to_write", net_calls_to_write_stat }, - {"proxy.process.net.calls_to_write_nodata", net_calls_to_write_nodata_stat }, - {"proxy.process.net.calls_to_writetonet", net_calls_to_writetonet_stat }, - {"proxy.process.net.inactivity_cop_lock_acquire_failure", inactivity_cop_lock_acquire_failure_stat}, - {"proxy.process.net.net_handler_run", net_handler_run_stat }, - {"proxy.process.net.read_bytes", net_read_bytes_stat }, - {"proxy.process.net.write_bytes", net_write_bytes_stat }, - {"proxy.process.net.fastopen_out.attempts", net_fastopen_attempts_stat }, - {"proxy.process.net.fastopen_out.successes", net_fastopen_successes_stat }, - {"proxy.process.socks.connections_successful", socks_connections_successful_stat }, - {"proxy.process.socks.connections_unsuccessful", socks_connections_unsuccessful_stat }, - }; - - const std::pair non_persistent[] = { - {"proxy.process.net.accepts_currently_open", net_accepts_currently_open_stat }, - {"proxy.process.net.connections_currently_open", net_connections_currently_open_stat }, - {"proxy.process.net.default_inactivity_timeout_applied", default_inactivity_timeout_applied_stat}, - {"proxy.process.net.default_inactivity_timeout_count", default_inactivity_timeout_count_stat }, - {"proxy.process.net.dynamic_keep_alive_timeout_in_count", keep_alive_queue_timeout_count_stat }, - {"proxy.process.net.dynamic_keep_alive_timeout_in_total", keep_alive_queue_timeout_total_stat }, - {"proxy.process.socks.connections_currently_open", socks_connections_currently_open_stat }, - }; - - for (auto &p : persistent) { - RecRegisterRawStat(net_rsb, RECT_PROCESS, p.first, RECD_INT, RECP_PERSISTENT, p.second, RecRawStatSyncSum); - } - - for (auto &p : non_persistent) { - RecRegisterRawStat(net_rsb, RECT_PROCESS, p.first, RECD_INT, RECP_NON_PERSISTENT, p.second, RecRawStatSyncSum); - } - - NET_CLEAR_DYN_STAT(net_handler_run_stat); - NET_CLEAR_DYN_STAT(net_connections_currently_open_stat); - NET_CLEAR_DYN_STAT(net_accepts_currently_open_stat); - NET_CLEAR_DYN_STAT(net_calls_to_readfromnet_stat); - NET_CLEAR_DYN_STAT(net_calls_to_read_stat); - NET_CLEAR_DYN_STAT(net_calls_to_read_nodata_stat); - NET_CLEAR_DYN_STAT(net_calls_to_writetonet_stat); - NET_CLEAR_DYN_STAT(net_calls_to_write_stat); - NET_CLEAR_DYN_STAT(net_calls_to_write_nodata_stat); - NET_CLEAR_DYN_STAT(socks_connections_currently_open_stat); - NET_CLEAR_DYN_STAT(keep_alive_queue_timeout_total_stat); - NET_CLEAR_DYN_STAT(keep_alive_queue_timeout_count_stat); - NET_CLEAR_DYN_STAT(default_inactivity_timeout_count_stat); - NET_CLEAR_DYN_STAT(default_inactivity_timeout_applied_stat); - - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.tcp.total_accepts", RECD_INT, RECP_NON_PERSISTENT, - static_cast(net_tcp_accept_stat), RecRawStatSyncSum); - NET_CLEAR_DYN_STAT(net_tcp_accept_stat); - - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.connections_throttled_in", RECD_INT, RECP_PERSISTENT, - (int)net_connections_throttled_in_stat, RecRawStatSyncSum); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.connections_throttled_out", RECD_INT, RECP_PERSISTENT, - (int)net_connections_throttled_out_stat, RecRawStatSyncSum); - RecRegisterRawStat(net_rsb, RECT_PROCESS, "proxy.process.net.max.requests_throttled_in", RECD_INT, RECP_PERSISTENT, - (int)net_requests_max_throttled_in_stat, RecRawStatSyncSum); + 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.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"); } void @@ -149,9 +118,6 @@ ink_net_init(ts::ModuleVersion version) ink_release_assert(version.check(NET_SYSTEM_MODULE_INTERNAL_VERSION)); if (!init_called) { - // do one time stuff - // create a stat block for NetStats - net_rsb = RecAllocateRawStatBlock(static_cast(Net_Stat_Count)); configure_net(); register_net_stats(); } diff --git a/iocore/net/NetHandler.cc b/iocore/net/NetHandler.cc index b46b67008c7..3cafbcc0aa2 100644 --- a/iocore/net/NetHandler.cc +++ b/iocore/net/NetHandler.cc @@ -313,7 +313,7 @@ NetHandler::waitForActivity(ink_hrtime timeout) IOUringContext *ur = IOUringContext::local_context(); #endif - NET_INCREMENT_DYN_STAT(net_handler_run_stat); + Metrics::increment(net_rsb.handler_run); SCOPED_MUTEX_LOCK(lock, mutex, this->thread); process_enabled_list(); @@ -468,8 +468,8 @@ NetHandler::_close_ne(NetEvent *ne, ink_hrtime now, int &handle_event, int &clos if (diff > 0) { total_idle_time += diff; ++total_idle_count; - NET_SUM_DYN_STAT(keep_alive_queue_timeout_total_stat, diff); - NET_INCREMENT_DYN_STAT(keep_alive_queue_timeout_count_stat); + Metrics::increment(net_rsb.keep_alive_queue_timeout_total, diff); + Metrics::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), @@ -547,7 +547,7 @@ NetHandler::add_to_active_queue(NetEvent *ne) } else { if (active_queue_full) { // there is no room left in the queue - NET_SUM_DYN_STAT(net_requests_max_throttled_in_stat, 1); + Metrics::increment(net_rsb.requests_max_throttled_in); return false; } // in the keep-alive queue or no queue, new to this queue diff --git a/iocore/net/OCSPStapling.cc b/iocore/net/OCSPStapling.cc index d117d42b168..f427cf85493 100644 --- a/iocore/net/OCSPStapling.cc +++ b/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: - SSL_INCREMENT_DYN_STAT(ssl_ocsp_revoked_cert_stat); + Metrics::increment(ssl_rsb.ocsp_revoked_cert); break; case TS_OCSP_CERTSTATUS_UNKNOWN: - SSL_INCREMENT_DYN_STAT(ssl_ocsp_unknown_cert_stat); + Metrics::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); - SSL_INCREMENT_DYN_STAT(ssl_ocsp_refreshed_cert_stat); + Metrics::increment(ssl_rsb.ocsp_refreshed_cert); } else { Error("Failed to refresh OCSP for %s certificate. url=%s", cinf->certname, cinf->uri); - SSL_INCREMENT_DYN_STAT(ssl_ocsp_refresh_cert_failure_stat); + Metrics::increment(ssl_rsb.ocsp_refresh_cert_failure); } } else { ink_mutex_release(&cinf->stapling_mutex); diff --git a/iocore/net/P_Net.h b/iocore/net/P_Net.h index 7516b106cd5..0d0fa0107ea 100644 --- a/iocore/net/P_Net.h +++ b/iocore/net/P_Net.h @@ -29,68 +29,50 @@ **************************************************************************/ #pragma once +#include "api/Metrics.h" + +using ts::Metrics; + // Net Stats -enum Net_Stats { - net_handler_run_stat, - net_read_bytes_stat, - net_write_bytes_stat, - net_connections_currently_open_stat, - net_accepts_currently_open_stat, - net_calls_to_readfromnet_stat, - net_calls_to_read_stat, - net_calls_to_read_nodata_stat, - net_calls_to_writetonet_stat, - net_calls_to_write_stat, - net_calls_to_write_nodata_stat, - socks_connections_successful_stat, - socks_connections_unsuccessful_stat, - socks_connections_currently_open_stat, - inactivity_cop_lock_acquire_failure_stat, - keep_alive_queue_timeout_total_stat, - keep_alive_queue_timeout_count_stat, - default_inactivity_timeout_applied_stat, - default_inactivity_timeout_count_stat, - net_fastopen_attempts_stat, - net_fastopen_successes_stat, - net_tcp_accept_stat, - net_connections_throttled_in_stat, - net_connections_throttled_out_stat, - net_requests_max_throttled_in_stat, - Net_Stat_Count +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 *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; }; -struct RecRawStatBlock; -extern RecRawStatBlock *net_rsb; +extern NetStatsBlock net_rsb; + #define SSL_HANDSHAKE_WANT_READ 6 #define SSL_HANDSHAKE_WANT_WRITE 7 #define SSL_HANDSHAKE_WANT_ACCEPT 8 #define SSL_HANDSHAKE_WANT_CONNECT 9 -#define NET_INCREMENT_DYN_STAT(_x) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, 1) - -#define NET_DECREMENT_DYN_STAT(_x) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, -1) - -#define NET_SUM_DYN_STAT(_x, _r) RecIncrRawStatSum(net_rsb, mutex->thread_holding, (int)_x, _r) - -#define NET_READ_DYN_SUM(_x, _sum) RecGetRawStatSum(net_rsb, (int)_x, &_sum) - -#define NET_READ_DYN_STAT(_x, _count, _sum) \ - do { \ - RecGetRawStatSum(net_rsb, (int)_x, &_sum); \ - RecGetRawStatCount(net_rsb, (int)_x, &_count); \ - } while (0) - -#define NET_CLEAR_DYN_STAT(x) \ - do { \ - RecSetRawStatSum(net_rsb, x, 0); \ - RecSetRawStatCount(net_rsb, x, 0); \ - } while (0); - -// For global access -#define NET_SUM_GLOBAL_DYN_STAT(_x, _r) RecIncrGlobalRawStatSum(net_rsb, (_x), (_r)) -#define NET_READ_GLOBAL_DYN_SUM(_x, _sum) RecGetGlobalRawStatSum(net_rsb, _x, &_sum) - #include "tscore/ink_platform.h" #include "P_EventSystem.h" #include "I_Net.h" diff --git a/iocore/net/P_SSLConfig.h b/iocore/net/P_SSLConfig.h index 924072341c1..5a85fae99f5 100644 --- a/iocore/net/P_SSLConfig.h +++ b/iocore/net/P_SSLConfig.h @@ -37,7 +37,6 @@ #include "swoc/swoc_ip.h" #include "tscore/ink_inet.h" - #include "ConfigProcessor.h" #include "SSLSessionCache.h" diff --git a/iocore/net/P_UnixNet.h b/iocore/net/P_UnixNet.h index 6dce358cc2a..af37bc1ff30 100644 --- a/iocore/net/P_UnixNet.h +++ b/iocore/net/P_UnixNet.h @@ -92,11 +92,9 @@ enum ThrottleType { TS_INLINE int net_connections_to_throttle(ThrottleType t) { - double headroom = t == ACCEPT ? NET_THROTTLE_ACCEPT_HEADROOM : NET_THROTTLE_CONNECT_HEADROOM; - int64_t sval = 0; + double headroom = t == ACCEPT ? NET_THROTTLE_ACCEPT_HEADROOM : NET_THROTTLE_CONNECT_HEADROOM; + int currently_open = static_cast(Metrics::read(net_rsb.connections_currently_open)); - NET_READ_GLOBAL_DYN_SUM(net_connections_currently_open_stat, sval); - int currently_open = static_cast(sval); // deal with race if we got to multiple net threads if (currently_open < 0) { currently_open = 0; diff --git a/iocore/net/QUICNetProcessor.cc b/iocore/net/QUICNetProcessor.cc index 5235b248bd7..85a011ab8a1 100644 --- a/iocore/net/QUICNetProcessor.cc +++ b/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"); } - NET_INCREMENT_DYN_STAT(net_accepts_currently_open_stat); + Metrics::increment(net_rsb.accepts_currently_open); if (opt.localhost_only) { accept_ip.setToLoopback(opt.ip_family); diff --git a/iocore/net/QUICNetProcessor_quiche.cc b/iocore/net/QUICNetProcessor_quiche.cc index f32ea7a84d9..66057289331 100644 --- a/iocore/net/QUICNetProcessor_quiche.cc +++ b/iocore/net/QUICNetProcessor_quiche.cc @@ -218,7 +218,6 @@ QUICNetProcessor::main_accept(Continuation *cont, SOCKET fd, AcceptOptions const Debug("iocore_net_processor", "NetProcessor::main_accept - port %d,recv_bufsize %d, send_bufsize %d, sockopt 0x%0x", opt.local_port, opt.recv_bufsize, opt.send_bufsize, opt.sockopt_flags); - ProxyMutex *mutex = this_ethread()->mutex.get(); int accept_threads = opt.accept_threads; // might be changed. IpEndpoint accept_ip; // local binding address. // char thr_name[MAX_THREAD_NAME_LENGTH]; @@ -228,7 +227,7 @@ QUICNetProcessor::main_accept(Continuation *cont, SOCKET fd, AcceptOptions const if (accept_threads < 0) { REC_ReadConfigInteger(accept_threads, "proxy.config.accept_threads"); } - NET_INCREMENT_DYN_STAT(net_accepts_currently_open_stat); + Metrics::increment(net_rsb.accepts_currently_open); if (opt.localhost_only) { accept_ip.setToLoopback(opt.ip_family); diff --git a/iocore/net/SSLDiags.cc b/iocore/net/SSLDiags.cc index cd75e1bcf64..d78ffbad2f3 100644 --- a/iocore/net/SSLDiags.cc +++ b/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)) { - SSL_INCREMENT_DYN_STAT(ssl_user_agent_other_errors_stat); + Metrics::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: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_expired_cert_stat); + Metrics::increment(ssl_rsb.user_agent_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_revoked_cert_stat); + Metrics::increment(ssl_rsb.user_agent_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_unknown_cert_stat); + Metrics::increment(ssl_rsb.user_agent_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_cert_verify_failed_stat); + Metrics::increment(ssl_rsb.user_agent_cert_verify_failed); break; case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_bad_cert_stat); + Metrics::increment(ssl_rsb.user_agent_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_decryption_failed_stat); + Metrics::increment(ssl_rsb.user_agent_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_wrong_version_stat); + Metrics::increment(ssl_rsb.user_agent_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_unknown_ca_stat); + Metrics::increment(ssl_rsb.user_agent_unknown_ca); break; default: - SSL_INCREMENT_DYN_STAT(ssl_user_agent_other_errors_stat); + Metrics::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)) { - SSL_INCREMENT_DYN_STAT(ssl_origin_server_other_errors_stat); + Metrics::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: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_expired_cert_stat); + Metrics::increment(ssl_rsb.origin_server_expired_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_revoked_cert_stat); + Metrics::increment(ssl_rsb.origin_server_revoked_cert); break; case SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_unknown_cert_stat); + Metrics::increment(ssl_rsb.origin_server_unknown_cert); break; case SSL_R_CERTIFICATE_VERIFY_FAILED: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_cert_verify_failed_stat); + Metrics::increment(ssl_rsb.origin_server_cert_verify_failed); break; case SSL_R_SSLV3_ALERT_BAD_CERTIFICATE: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_bad_cert_stat); + Metrics::increment(ssl_rsb.origin_server_bad_cert); break; case SSL_R_TLSV1_ALERT_DECRYPTION_FAILED: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_decryption_failed_stat); + Metrics::increment(ssl_rsb.origin_server_decryption_failed); break; case SSL_R_WRONG_VERSION_NUMBER: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_wrong_version_stat); + Metrics::increment(ssl_rsb.origin_server_wrong_version); break; case SSL_R_TLSV1_ALERT_UNKNOWN_CA: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_unknown_ca_stat); + Metrics::increment(ssl_rsb.origin_server_unknown_ca); break; default: - SSL_INCREMENT_DYN_STAT(ssl_origin_server_other_errors_stat); + Metrics::increment(ssl_rsb.origin_server_other_errors); return false; } diff --git a/iocore/net/SSLNetProcessor.cc b/iocore/net/SSLNetProcessor.cc index 815eb19c815..16ffdb240ef 100644 --- a/iocore/net/SSLNetProcessor.cc +++ b/iocore/net/SSLNetProcessor.cc @@ -65,9 +65,6 @@ SSLNetProcessor::start(int, size_t stacksize) } SSLTicketKeyConfig::startup(); - // Acquire a SSLConfigParams instance *after* we start SSL up. - // SSLConfig::scoped_config params; - // Initialize SSL statistics. This depends on an initial set of certificates being loaded above. SSLInitializeStatistics(); diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc index 4e4fcdab6e5..f30353017e3 100644 --- a/iocore/net/SSLNetVConnection.cc +++ b/iocore/net/SSLNetVConnection.cc @@ -348,7 +348,7 @@ SSLNetVConnection::_ssl_read_from_net(EThread *lthread, int64_t &ret) case SSL_ERROR_SYSCALL: if (nread != 0) { // not EOF - SSL_INCREMENT_DYN_STAT(ssl_error_syscall); + Metrics::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)); @@ -368,7 +368,8 @@ SSLNetVConnection::_ssl_read_from_net(EThread *lthread, int64_t &ret) ERR_error_string_n(e, buf, sizeof(buf)); event = SSL_READ_ERROR; ret = errno; - SSL_CLR_ERR_INCR_DYN_STAT(this, ssl_error_ssl, "errno=%d", errno); + SSLVCDebug(this, "errno=%d", errno); + Metrics::increment(ssl_rsb.error_ssl); } break; } // switch } // while @@ -419,7 +420,7 @@ SSLNetVConnection::read_raw_data() b = b->next.get(); r = SocketManager::read(this->con.fd, buffer, buf_len); - NET_INCREMENT_DYN_STAT(net_calls_to_read_stat); + Metrics::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, @@ -441,7 +442,8 @@ SSLNetVConnection::read_raw_data() r = total_read - rattempted + r; } } - NET_SUM_DYN_STAT(net_read_bytes_stat, r); + Metrics::increment(net_rsb.read_bytes, r); + Metrics::increment(net_rsb.read_bytes_count); swoc::IPRangeSet *pp_ipmap; pp_ipmap = SSLConfigParams::proxy_protocol_ip_addrs; @@ -511,7 +513,7 @@ SSLNetVConnection::read_raw_data() // check for errors if (r <= 0) { if (r == -EAGAIN || r == -ENOTCONN) { - NET_INCREMENT_DYN_STAT(net_calls_to_read_nodata_stat); + Metrics::increment(net_rsb.calls_to_read_nodata); } } @@ -829,10 +831,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; - SSL_INCREMENT_DYN_STAT(ssl_total_dyn_def_tls_record_count); + Metrics::increment(ssl_rsb.total_dyn_def_tls_record_count); } else { dynamic_tls_record_size = SSL_MAX_TLS_RECORD_SIZE; - SSL_INCREMENT_DYN_STAT(ssl_total_dyn_max_tls_record_count); + Metrics::increment(ssl_rsb.total_dyn_max_tls_record_count); } if (l > dynamic_tls_record_size) { l = dynamic_tls_record_size; @@ -857,7 +859,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); - NET_INCREMENT_DYN_STAT(net_calls_to_write_stat); + Metrics::increment(net_rsb.calls_to_write); } while (num_really_written == try_to_write && total_written < towrite); if (total_written > 0) { @@ -894,7 +896,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; - SSL_INCREMENT_DYN_STAT(ssl_error_syscall); + Metrics::increment(ssl_rsb.error_syscall); Dbg(dbg_ctl_ssl_error, "SSL_write-SSL_ERROR_SYSCALL"); break; // end of stream @@ -906,7 +908,8 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &buf default: { // Treat SSL_ERROR_SSL as EPIPE error. num_really_written = -EPIPE; - SSL_CLR_ERR_INCR_DYN_STAT(this, ssl_error_ssl, "SSL_write-SSL_ERROR_SSL errno=%d", errno); + SSLVCDebug(this, "SSL_write-SSL_ERROR_SSL errno=%d", errno); + Metrics::increment(ssl_rsb.error_ssl); } break; } } @@ -1021,7 +1024,7 @@ SSLNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, -1); + Metrics::decrement(net_rsb.connections_currently_open); } con.close(); @@ -1218,7 +1221,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()); - SSL_INCREMENT_DYN_STAT(ssl_sni_name_set_failure); + Metrics::increment(ssl_rsb.sni_name_set_failure); } } @@ -1252,7 +1255,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) // Go do the preaccept hooks if (sslHandshakeHookState == HANDSHAKE_HOOKS_PRE) { - SSL_INCREMENT_DYN_STAT(ssl_total_attempts_handshake_count_in_stat); + Metrics::increment(ssl_rsb.total_attempts_handshake_count_in); if (!curHook) { Dbg(dbg_ctl_ssl, "Initialize preaccept curHook from NULL"); curHook = ssl_hooks->get(TSSslHookInternalID(TS_VCONN_START_HOOK)); @@ -1391,7 +1394,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) if (this->get_tls_handshake_begin_time()) { this->_record_tls_handshake_end_time(); - SSL_INCREMENT_DYN_STAT(ssl_total_success_handshake_count_in_stat); + Metrics::increment(ssl_rsb.total_success_handshake_count_in); } if (this->get_tunnel_type() != SNIRoutingType::NONE) { @@ -1473,7 +1476,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) #if TS_USE_TLS_ASYNC case SSL_ERROR_WANT_ASYNC: - SSL_INCREMENT_DYN_STAT(ssl_error_async); + Metrics::increment(ssl_rsb.error_async); return SSL_WAIT_FOR_ASYNC; #endif @@ -1481,7 +1484,7 @@ SSLNetVConnection::sslServerHandShakeEvent(int &err) return EVENT_CONT; case SSL_ERROR_SSL: { - SSL_CLR_ERR_INCR_DYN_STAT(this, ssl_error_ssl, "SSLNetVConnection::sslServerHandShakeEvent, SSL_ERROR_SSL errno=%d", errno); + SSLVCDebug(this, "SSLNetVConnection::sslServerHandShakeEvent, SSL_ERROR_SSL errno=%d", errno); return EVENT_ERROR; } @@ -1543,7 +1546,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) // Go do the preaccept hooks if (sslHandshakeHookState == HANDSHAKE_HOOKS_OUTBOUND_PRE) { - SSL_INCREMENT_DYN_STAT(ssl_total_attempts_handshake_count_out_stat); + Metrics::increment(ssl_rsb.total_attempts_handshake_count_out); if (!curHook) { Dbg(dbg_ctl_ssl, "Initialize outbound connect curHook from NULL"); curHook = ssl_hooks->get(TSSslHookInternalID(TS_VCONN_OUTBOUND_START_HOOK)); @@ -1593,7 +1596,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) writeReschedule(nh); } - SSL_INCREMENT_DYN_STAT(ssl_total_success_handshake_count_out_stat); + Metrics::increment(ssl_rsb.total_success_handshake_count_out); sslHandshakeStatus = SSL_HANDSHAKE_DONE; return EVENT_DONE; @@ -1626,7 +1629,7 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) case SSL_ERROR_SYSCALL: err = errno; - SSL_INCREMENT_DYN_STAT(ssl_error_syscall); + Metrics::increment(ssl_rsb.error_syscall); Dbg(dbg_ctl_ssl_error, "syscall"); return EVENT_ERROR; break; @@ -1637,8 +1640,9 @@ SSLNetVConnection::sslClientHandShakeEvent(int &err) char buf[512]; unsigned long e = ERR_peek_last_error(); ERR_error_string_n(e, buf, sizeof(buf)); - // FIXME -- This triggers a retry on cases of cert validation errors.... - SSL_CLR_ERR_INCR_DYN_STAT(this, ssl_error_ssl, "SSL_ERROR_SSL errno=%d", errno); + // 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); Dbg(dbg_ctl_ssl_error, "SSL_ERROR_SSL"); if (e) { if (this->options.sni_servername) { @@ -1941,20 +1945,20 @@ SSLNetVConnection::increment_ssl_version_metric(int version) const { switch (version) { case SSL3_VERSION: - SSL_INCREMENT_DYN_STAT(ssl_total_sslv3); + Metrics::increment(ssl_rsb.total_sslv3); break; case TLS1_VERSION: - SSL_INCREMENT_DYN_STAT(ssl_total_tlsv1); + Metrics::increment(ssl_rsb.total_tlsv1); break; case TLS1_1_VERSION: - SSL_INCREMENT_DYN_STAT(ssl_total_tlsv11); + Metrics::increment(ssl_rsb.total_tlsv11); break; case TLS1_2_VERSION: - SSL_INCREMENT_DYN_STAT(ssl_total_tlsv12); + Metrics::increment(ssl_rsb.total_tlsv12); break; #ifdef TLS1_3_VERSION case TLS1_3_VERSION: - SSL_INCREMENT_DYN_STAT(ssl_total_tlsv13); + Metrics::increment(ssl_rsb.total_tlsv13); break; #endif default: @@ -2228,7 +2232,7 @@ SSLNetVConnection::_ssl_accept() } block->fill(nread); this->_early_data_buf->append_block(block); - SSL_INCREMENT_DYN_STAT(ssl_early_data_received_count); + Metrics::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); @@ -2303,7 +2307,7 @@ SSLNetVConnection::_ssl_connect() if (ret > 0) { if (SSL_session_reused(ssl)) { - SSL_INCREMENT_DYN_STAT(ssl_origin_session_reused_count); + Metrics::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"); @@ -2455,7 +2459,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); - SSL_INCREMENT_DYN_STAT(ssl_early_data_received_count); + Metrics::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/iocore/net/SSLSessionCache.cc b/iocore/net/SSLSessionCache.cc index 0e7f0323d77..e978ffc3d22 100644 --- a/iocore/net/SSLSessionCache.cc +++ b/iocore/net/SSLSessionCache.cc @@ -91,10 +91,8 @@ 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); - if (ssl_rsb) { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_eviction); - } bucket->removeSession(sid); } @@ -120,9 +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()) { - if (ssl_rsb) { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_lock_contention); - } + Metrics::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return; } @@ -166,9 +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()) { - if (ssl_rsb) { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_lock_contention); - } + Metrics::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return; } @@ -177,9 +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) { - if (ssl_rsb) { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_eviction); - } + Metrics::increment(ssl_rsb.session_cache_eviction); removeOldestSession(w_lock); } @@ -197,9 +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()) { - if (ssl_rsb) { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_lock_contention); - } + Metrics::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return true_len; } @@ -232,9 +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()) { - if (ssl_rsb) { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_lock_contention); - } + Metrics::increment(ssl_rsb.session_cache_lock_contention); if (SSLConfigParams::session_cache_skip_on_lock_contention) { return false; } diff --git a/iocore/net/SSLStats.cc b/iocore/net/SSLStats.cc index 13f247c17c1..25d065b1fe9 100644 --- a/iocore/net/SSLStats.cc +++ b/iocore/net/SSLStats.cc @@ -27,15 +27,15 @@ #include "P_SSLConfig.h" #include "P_SSLUtils.h" +#include "records/P_RecProcess.h" -RecRawStatBlock *ssl_rsb = nullptr; -std::unordered_map cipher_map; +SSLStatsBlock ssl_rsb; +std::unordered_map cipher_map; -static int -SSLRecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id) +// ToDo: This gets called once per global sync, for now at least. +void +SSLPeriodicMetricsUpdate() { - // Grab all the stats we want from OpenSSL and set the stats. This function only needs to be called by one of the - // involved stats, all others *must* call RecRawStatSyncSum. SSLCertificateConfig::scoped_config certLookup; int64_t sessions = 0; @@ -43,6 +43,7 @@ SSLRecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecR int64_t misses = 0; int64_t timeouts = 0; + Debug("ssl", "Starting to update the new session metrics"); if (certLookup) { const unsigned ctxCount = certLookup->count(); for (size_t i = 0; i < ctxCount; i++) { @@ -59,31 +60,21 @@ SSLRecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecR } } - SSL_SET_COUNT_DYN_STAT(ssl_user_agent_sessions_stat, sessions); - SSL_SET_COUNT_DYN_STAT(ssl_user_agent_session_hit_stat, hits); - SSL_SET_COUNT_DYN_STAT(ssl_user_agent_session_miss_stat, misses); - SSL_SET_COUNT_DYN_STAT(ssl_user_agent_session_timeout_stat, timeouts); - - return RecRawStatSyncCount(name, data_type, data, rsb, id); + 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); } static void -add_cipher_stat(const char *cipherName, const std::string &statName, int index) +add_cipher_stat(const char *cipherName, const std::string &statName) { - // If room in allocated space ... - if ((ssl_cipher_stats_start + index) > ssl_cipher_stats_end) { - // Too many ciphers, increase ssl_cipher_stats_end. - SSLError("too many ciphers to register metric '%s', increase SSL_Stats::ssl_cipher_stats_end", statName.c_str()); - return; - } - // If not already registered ... if (cipherName && cipher_map.find(cipherName) == cipher_map.end()) { - cipher_map.emplace(cipherName, static_cast(ssl_cipher_stats_start + index)); - // Register as non-persistent since the order/index is dependent upon configuration. - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, statName.c_str(), RECD_INT, RECP_NON_PERSISTENT, (int)ssl_cipher_stats_start + index, - RecRawStatSyncSum); - SSL_CLEAR_DYN_STAT((int)ssl_cipher_stats_start + index); + ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::IntType *metric = intm.newMetricPtr(statName); + + cipher_map.emplace(cipherName, metric); Debug("ssl", "registering SSL cipher metric '%s'", statName.c_str()); } } @@ -94,181 +85,90 @@ SSLInitializeStatistics() SSL_CTX *ctx; SSL *ssl; STACK_OF(SSL_CIPHER) * ciphers; - - // Allocate SSL statistics block. - ssl_rsb = RecAllocateRawStatBlock(static_cast(Ssl_Stat_Count)); - ink_assert(ssl_rsb != nullptr); - - // SSL client errors. - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_other_errors", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_other_errors_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_expired_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_expired_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_revoked_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_revoked_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_unknown_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_unknown_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_cert_verify_failed", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_cert_verify_failed_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_bad_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_bad_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_decryption_failed", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_decryption_failed_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_wrong_version", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_wrong_version_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_unknown_ca", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_user_agent_unknown_ca_stat, RecRawStatSyncSum); - - // Polled SSL context statistics. - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_sessions", RECD_COUNTER, RECP_NON_PERSISTENT, - (int)ssl_user_agent_sessions_stat, - SSLRecRawStatSyncCount); //<- only use this fn once - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_session_hit", RECD_COUNTER, RECP_NON_PERSISTENT, - (int)ssl_user_agent_session_hit_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_session_miss", RECD_COUNTER, RECP_NON_PERSISTENT, - (int)ssl_user_agent_session_miss_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.user_agent_session_timeout", RECD_COUNTER, RECP_NON_PERSISTENT, - (int)ssl_user_agent_session_timeout_stat, RecRawStatSyncCount); - - // SSL server errors. - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_other_errors", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_other_errors_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_expired_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_expired_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_revoked_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_revoked_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_unknown_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_unknown_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_cert_verify_failed", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_cert_verify_failed_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_bad_cert", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_bad_cert_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_decryption_failed", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_decryption_failed_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_wrong_version", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_wrong_version_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_server_unknown_ca", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_server_unknown_ca_stat, RecRawStatSyncSum); - - // SSL handshake time - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_handshake_time", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_handshake_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_attempts_handshake_count_in", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_attempts_handshake_count_in_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_success_handshake_count_in", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_success_handshake_count_in_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_attempts_handshake_count_out", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_attempts_handshake_count_out_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_success_handshake_count_out", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_success_handshake_count_out_stat, RecRawStatSyncCount); - - // TLS tickets - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_tickets_created", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tickets_created_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_tickets_verified", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tickets_verified_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_tickets_not_found", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tickets_not_found_stat, RecRawStatSyncCount); - // TODO: ticket renewal is not used right now. - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_tickets_renewed", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tickets_renewed_stat, RecRawStatSyncCount); - // The number of session tickets verified with an "old" key. - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_tickets_verified_old_key", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tickets_verified_old_key_stat, RecRawStatSyncCount); - // The number of ticket keys renewed. - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.total_ticket_keys_renewed", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_ticket_keys_renewed_stat, RecRawStatSyncCount); - - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_session_cache_hit", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_session_cache_hit, RecRawStatSyncCount); - - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_origin_session_cache_hit", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_session_cache_hit, RecRawStatSyncCount); - - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_session_cache_new_session", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_session_cache_new_session, RecRawStatSyncCount); - - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_session_cache_miss", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_session_cache_miss, RecRawStatSyncCount); - - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_origin_session_cache_miss", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_origin_session_cache_miss, RecRawStatSyncCount); - - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_session_cache_eviction", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_session_cache_eviction, RecRawStatSyncCount); - - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_session_cache_lock_contention", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_session_cache_lock_contention, RecRawStatSyncCount); - - // Track dynamic record size - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.default_record_size_count", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_dyn_def_tls_record_count, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.max_record_size_count", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_dyn_max_tls_record_count, RecRawStatSyncSum); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.redo_record_size_count", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_dyn_redo_tls_record_count, RecRawStatSyncCount); - - // error stats - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_error_syscall", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_error_syscall, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_error_ssl", RECD_COUNTER, RECP_PERSISTENT, (int)ssl_error_ssl, - RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_error_async", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_error_async, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_sni_name_set_failure", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_sni_name_set_failure, RecRawStatSyncCount); - - // ocsp stapling stats - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_ocsp_revoked_cert_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_ocsp_revoked_cert_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_ocsp_unknown_cert_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_ocsp_unknown_cert_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_ocsp_refreshed_cert", RECD_INT, RECP_PERSISTENT, - (int)ssl_ocsp_refreshed_cert_stat, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_ocsp_refresh_cert_failure", RECD_INT, RECP_PERSISTENT, - (int)ssl_ocsp_refresh_cert_failure_stat, RecRawStatSyncCount); - - // SSL Version stats - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_total_sslv3", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_sslv3, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_total_tlsv1", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tlsv1, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_total_tlsv11", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tlsv11, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_total_tlsv12", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tlsv12, RecRawStatSyncCount); - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.ssl_total_tlsv13", RECD_COUNTER, RECP_PERSISTENT, - (int)ssl_total_tlsv13, RecRawStatSyncCount); - - // TLSv1.3 0-RTT stats - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.early_data_received", RECD_INT, RECP_PERSISTENT, - (int)ssl_early_data_received_count, RecRawStatSyncCount); - - // Origin Server Session Reuse stats - RecRegisterRawStat(ssl_rsb, RECT_PROCESS, "proxy.process.ssl.origin_session_reused", RECD_INT, RECP_PERSISTENT, - (int)ssl_origin_session_reused_count, RecRawStatSyncCount); + 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_stat"); + ssl_rsb.ocsp_unknown_cert = intm.newMetricPtr("proxy.process.ssl.ssl_ocsp_unknown_cert_stat"); + 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"); // 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 // filtered by proxy.config.ssl.server.cipher_suite. This keeps the set of cipher suites stable across // configuration reloads and works for the case where we honor the client cipher preference. - SSLMultiCertConfigLoader loader(nullptr); ctx = loader.default_server_ssl_ctx(); ssl = SSL_new(ctx); ciphers = SSL_get_ciphers(ssl); // BoringSSL has sk_SSL_CIPHER_num() return a size_t (well, sk_num() is) - int index; - for (index = 0; index < static_cast(sk_SSL_CIPHER_num(ciphers)); index++) { + for (int index = 0; index < static_cast(sk_SSL_CIPHER_num(ciphers)); index++) { SSL_CIPHER *cipher = const_cast(sk_SSL_CIPHER_value(ciphers, index)); const char *cipherName = SSL_CIPHER_get_name(cipher); std::string statName = "proxy.process.ssl.cipher.user_agent." + std::string(cipherName); - add_cipher_stat(cipherName, statName, index); + + add_cipher_stat(cipherName, statName); } // Add "OTHER" for ciphers not on the map - add_cipher_stat(SSL_CIPHER_STAT_OTHER.c_str(), "proxy.process.ssl.cipher.user_agent." + SSL_CIPHER_STAT_OTHER, index); + add_cipher_stat(SSL_CIPHER_STAT_OTHER.c_str(), "proxy.process.ssl.cipher.user_agent." + SSL_CIPHER_STAT_OTHER); SSL_free(ssl); SSLReleaseContext(ctx); diff --git a/iocore/net/SSLStats.h b/iocore/net/SSLStats.h index 8d0ba02de9a..051e2576a74 100644 --- a/iocore/net/SSLStats.h +++ b/iocore/net/SSLStats.h @@ -28,96 +28,77 @@ #include "records/I_RecProcess.h" #include "SSLDiags.h" -/* Stats should only be accessed using these macros */ -#define SSL_INCREMENT_DYN_STAT(x) RecIncrRawStat(ssl_rsb, nullptr, (int)x, 1) -#define SSL_DECREMENT_DYN_STAT(x) RecIncrRawStat(ssl_rsb, nullptr, (int)x, -1) -#define SSL_SET_COUNT_DYN_STAT(x, count) RecSetRawStatCount(ssl_rsb, x, count) -#define SSL_INCREMENT_DYN_STAT_EX(x, y) RecIncrRawStat(ssl_rsb, nullptr, (int)x, y) -#define SSL_CLEAR_DYN_STAT(x) \ - do { \ - RecSetRawStatSum(ssl_rsb, (x), 0); \ - RecSetRawStatCount(ssl_rsb, (x), 0); \ - } while (0) -#define SSL_CLR_ERR_INCR_DYN_STAT(vc, x, fmt, ...) \ - do { \ - SSLVCDebug((vc), fmt, ##__VA_ARGS__); \ - RecIncrRawStat(ssl_rsb, nullptr, (int)x, 1); \ - } while (0) - -enum SSL_Stats { - ssl_origin_server_expired_cert_stat, - ssl_user_agent_expired_cert_stat, - ssl_origin_server_revoked_cert_stat, - ssl_user_agent_revoked_cert_stat, - ssl_origin_server_unknown_cert_stat, - ssl_user_agent_unknown_cert_stat, - ssl_origin_server_cert_verify_failed_stat, - ssl_user_agent_cert_verify_failed_stat, - ssl_origin_server_bad_cert_stat, - ssl_user_agent_bad_cert_stat, - ssl_origin_server_decryption_failed_stat, - ssl_user_agent_decryption_failed_stat, - ssl_origin_server_wrong_version_stat, - ssl_user_agent_wrong_version_stat, - ssl_origin_server_other_errors_stat, - ssl_user_agent_other_errors_stat, - ssl_origin_server_unknown_ca_stat, - ssl_user_agent_unknown_ca_stat, - ssl_user_agent_sessions_stat, - ssl_user_agent_session_hit_stat, - ssl_user_agent_session_miss_stat, - ssl_user_agent_session_timeout_stat, - ssl_total_handshake_time_stat, - ssl_total_attempts_handshake_count_in_stat, - ssl_total_success_handshake_count_in_stat, - ssl_total_tickets_created_stat, - ssl_total_tickets_verified_stat, - ssl_total_tickets_verified_old_key_stat, // verified with old key. - ssl_total_ticket_keys_renewed_stat, // number of keys renewed. - ssl_total_tickets_not_found_stat, - ssl_total_tickets_renewed_stat, - ssl_total_dyn_def_tls_record_count, - ssl_total_dyn_max_tls_record_count, - ssl_total_dyn_redo_tls_record_count, - ssl_session_cache_hit, - ssl_origin_session_cache_hit, - ssl_session_cache_miss, - ssl_origin_session_cache_miss, - ssl_session_cache_eviction, - ssl_session_cache_lock_contention, - ssl_session_cache_new_session, - ssl_early_data_received_count, // how many times we received early data - ssl_origin_session_reused_count, - - /* error stats */ - ssl_error_syscall, - ssl_error_ssl, - ssl_error_async, - ssl_sni_name_set_failure, - ssl_total_attempts_handshake_count_out_stat, - ssl_total_success_handshake_count_out_stat, - - /* ocsp stapling stats */ - ssl_ocsp_revoked_cert_stat, - ssl_ocsp_unknown_cert_stat, - ssl_ocsp_refreshed_cert_stat, - ssl_ocsp_refresh_cert_failure_stat, - - /* SSL/TLS versions */ - ssl_total_sslv3, - ssl_total_tlsv1, - ssl_total_tlsv11, - ssl_total_tlsv12, - ssl_total_tlsv13, - - ssl_cipher_stats_start = 100, - ssl_cipher_stats_end = 300, - - Ssl_Stat_Count +#include "api/Metrics.h" + +using ts::Metrics; + +// For some odd reason, these have to be initialized with nullptr, because the order +// of initialization and how we load certs is weird... In reality only the metric +// for ssl_rsb.total_ticket_keys_renewed needs this initialization, but lets be +// consistent at least. +struct SSLStatsBlock { + 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; }; -extern RecRawStatBlock *ssl_rsb; -extern std::unordered_map cipher_map; +extern SSLStatsBlock ssl_rsb; +extern std::unordered_map cipher_map; // Initialize SSL statistics. void SSLInitializeStatistics(); diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc index 5c056e29775..def98ce2121 100644 --- a/iocore/net/SSLUtils.cc +++ b/iocore/net/SSLUtils.cc @@ -224,7 +224,7 @@ ssl_new_cached_session(SSL *ssl, SSL_SESSION *sess) } } - SSL_INCREMENT_DYN_STAT(ssl_session_cache_new_session); + Metrics::increment(ssl_rsb.session_cache_new_session); session_cache->insertSession(sid, sess, ssl); // Call hook after new session is created @@ -645,14 +645,14 @@ ssl_context_enable_tickets(SSL_CTX *ctx, const char *ticket_key_path) keyblock = ssl_create_ticket_keyblock(ticket_key_path); - // Increase the stats. - if (ssl_rsb != nullptr) { // ssl_rsb is not initialized during the first run. - SSL_INCREMENT_DYN_STAT(ssl_total_ticket_keys_renewed_stat); + // 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); } - // Setting the callback can only fail if OpenSSL does not recognize the - // SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB constant. we set the callback first - // so that we don't leave a ticket_key pointer attached if it fails. +// Setting the callback can only fail if OpenSSL does not recognize the +// SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB constant. we set the callback first +// so that we don't leave a ticket_key pointer attached if it fails. #ifdef HAVE_SSL_CTX_SET_TLSEXT_TICKET_KEY_EVP_CB if (SSL_CTX_set_tlsext_ticket_key_evp_cb(ctx, ssl_callback_session_ticket) == 0) { #else @@ -1129,7 +1129,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()); } - SSL_INCREMENT_DYN_STAT((intptr_t)it->second); + Metrics::increment(it->second); } } } diff --git a/iocore/net/Socks.cc b/iocore/net/Socks.cc index b987116e8e2..f8ab5b967a8 100644 --- a/iocore/net/Socks.cc +++ b/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); - NET_INCREMENT_DYN_STAT(socks_connections_unsuccessful_stat); + Metrics::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"); - NET_INCREMENT_DYN_STAT(socks_connections_successful_stat); + Metrics::increment(net_rsb.socks_connections_successful); action_.continuation->handleEvent(NET_EVENT_OPEN, netVConnection); } } diff --git a/iocore/net/TLSBasicSupport.cc b/iocore/net/TLSBasicSupport.cc index a27f9d5e49e..2236334903e 100644 --- a/iocore/net/TLSBasicSupport.cc +++ b/iocore/net/TLSBasicSupport.cc @@ -130,5 +130,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); - SSL_INCREMENT_DYN_STAT_EX(ssl_total_handshake_time_stat, ssl_handshake_time); + Metrics::increment(ssl_rsb.total_handshake_time, ssl_handshake_time); } diff --git a/iocore/net/TLSSessionResumptionSupport.cc b/iocore/net/TLSSessionResumptionSupport.cc index 79e45611d72..e1da9698926 100644 --- a/iocore/net/TLSSessionResumptionSupport.cc +++ b/iocore/net/TLSSessionResumptionSupport.cc @@ -164,7 +164,7 @@ TLSSessionResumptionSupport::getSession(SSL *ssl, const unsigned char *id, int l // Double check the timeout if (is_ssl_session_timed_out(session)) { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_miss); + Metrics::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) @@ -173,12 +173,12 @@ TLSSessionResumptionSupport::getSession(SSL *ssl, const unsigned char *id, int l SSL_SESSION_free(session); session = nullptr; } else { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_hit); + Metrics::increment(ssl_rsb.session_cache_hit); this->_setSSLSessionCacheHit(true); this->_setSSLCurveNID(exdata->curve); } } else { - SSL_INCREMENT_DYN_STAT(ssl_session_cache_miss); + Metrics::increment(ssl_rsb.session_cache_miss); } return session; } @@ -192,16 +192,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())) { - SSL_INCREMENT_DYN_STAT(ssl_origin_session_cache_miss); + Metrics::increment(ssl_rsb.origin_session_cache_miss); origin_sess_cache->remove_session(lookup_key); shared_sess.reset(); } else { - SSL_INCREMENT_DYN_STAT(ssl_origin_session_cache_hit); + Metrics::increment(ssl_rsb.origin_session_cache_hit); this->_setSSLOriginSessionCacheHit(true); this->_setSSLCurveNID(curve); } } else { - SSL_INCREMENT_DYN_STAT(ssl_origin_session_cache_miss); + Metrics::increment(ssl_rsb.origin_session_cache_miss); } return shared_sess; } @@ -247,7 +247,7 @@ TLSSessionResumptionSupport::_setSessionInformation(ssl_ticket_key_block *keyblo #endif Debug("ssl_session_ticket", "create ticket for a new session."); - SSL_INCREMENT_DYN_STAT(ssl_total_tickets_created_stat); + Metrics::increment(ssl_rsb.total_tickets_created); return 1; } @@ -283,10 +283,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. - SSL_INCREMENT_DYN_STAT(ssl_total_tickets_verified_stat); + Metrics::increment(ssl_rsb.total_tickets_verified); if (i != 0) { // The number of tickets decrypted with "older" keys. - SSL_INCREMENT_DYN_STAT(ssl_total_tickets_verified_old_key_stat); + Metrics::increment(ssl_rsb.total_tickets_verified_old_key); } this->_setSSLSessionCacheHit(true); @@ -304,7 +304,7 @@ TLSSessionResumptionSupport::_getSessionInformation(ssl_ticket_key_block *keyblo } Debug("ssl_session_ticket", "keyname is not consistent."); - SSL_INCREMENT_DYN_STAT(ssl_total_tickets_not_found_stat); + Metrics::increment(ssl_rsb.total_tickets_not_found); return 0; } diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc index 44e1f3676b5..52e6ee068b3 100644 --- a/iocore/net/UnixNet.cc +++ b/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()) { - NET_INCREMENT_DYN_STAT(inactivity_cop_lock_acquire_failure_stat); + Metrics::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; - NET_INCREMENT_DYN_STAT(default_inactivity_timeout_applied_stat); + Metrics::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); - NET_INCREMENT_DYN_STAT(default_inactivity_timeout_count_stat); + Metrics::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; - NET_SUM_DYN_STAT(keep_alive_queue_timeout_total_stat, diff); - NET_INCREMENT_DYN_STAT(keep_alive_queue_timeout_count_stat); + Metrics::increment(net_rsb.keep_alive_queue_timeout_total, diff); + Metrics::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/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc index 138208b6e75..2ac59090c2a 100644 --- a/iocore/net/UnixNetAccept.cc +++ b/iocore/net/UnixNetAccept.cc @@ -81,7 +81,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) count = res; goto Ldone; } - NET_SUM_GLOBAL_DYN_STAT(net_tcp_accept_stat, 1); + Metrics::increment(net_rsb.tcp_accept); vc = static_cast(na->getNetProcessor()->allocate_vc(e->ethread)); if (!vc) { @@ -89,7 +89,7 @@ net_accept(NetAccept *na, void *ep, bool blockable) } ++count; - NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1); + Metrics::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -329,7 +329,7 @@ NetAccept::do_blocking_accept(EThread *t) check_throttle_warning(ACCEPT); // close the connection as we are in throttle state con.close(); - NET_SUM_DYN_STAT(net_connections_throttled_in_stat, 1); + Metrics::increment(net_rsb.connections_throttled_in); continue; } @@ -337,7 +337,7 @@ NetAccept::do_blocking_accept(EThread *t) return -1; } - NET_SUM_GLOBAL_DYN_STAT(net_tcp_accept_stat, 1); + Metrics::increment(net_rsb.tcp_accept); // Use 'nullptr' to Bypass thread allocator vc = (UnixNetVConnection *)this->getNetProcessor()->allocate_vc(nullptr); @@ -345,7 +345,7 @@ NetAccept::do_blocking_accept(EThread *t) return -1; } - NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1); + Metrics::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -400,14 +400,14 @@ NetAccept::acceptEvent(int event, void *ep) if (lock.is_locked()) { if (action_->cancelled) { e->cancel(); - NET_DECREMENT_DYN_STAT(net_accepts_currently_open_stat); + Metrics::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } int res; if ((res = accept_fn(this, e, false)) < 0) { - NET_DECREMENT_DYN_STAT(net_accepts_currently_open_stat); + Metrics::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" @@ -445,11 +445,11 @@ NetAccept::acceptFastEvent(int event, void *ep) if (check_net_throttle(ACCEPT)) { // close the connection as we are in throttle state con.close(); - NET_SUM_DYN_STAT(net_connections_throttled_in_stat, 1); + Metrics::increment(net_rsb.connections_throttled_in); continue; } Dbg(dbg_ctl_iocore_net, "accepted a new socket: %d", fd); - NET_SUM_GLOBAL_DYN_STAT(net_tcp_accept_stat, 1); + Metrics::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); @@ -498,7 +498,7 @@ NetAccept::acceptFastEvent(int event, void *ep) vc = (UnixNetVConnection *)this->getNetProcessor()->allocate_vc(e->ethread); ink_release_assert(vc); - NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1); + Metrics::increment(net_rsb.connections_currently_open); vc->id = net_next_connection_number(); vc->con.move(con); vc->set_remote_addr(con.addr); @@ -541,7 +541,7 @@ NetAccept::acceptFastEvent(int event, void *ep) Lerror: server.close(); e->cancel(); - NET_DECREMENT_DYN_STAT(net_accepts_currently_open_stat); + Metrics::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } @@ -558,7 +558,7 @@ NetAccept::acceptLoopEvent(int event, Event *e) } // Don't think this ever happens ... - NET_DECREMENT_DYN_STAT(net_accepts_currently_open_stat); + Metrics::decrement(net_rsb.accepts_currently_open); delete this; return EVENT_DONE; } diff --git a/iocore/net/UnixNetProcessor.cc b/iocore/net/UnixNetProcessor.cc index 87ed2035cb9..11e19fc949c 100644 --- a/iocore/net/UnixNetProcessor.cc +++ b/iocore/net/UnixNetProcessor.cc @@ -80,11 +80,9 @@ Action * UnixNetProcessor::accept_internal(Continuation *cont, int fd, AcceptOptions const &opt) { static int net_accept_number = 0; - - ProxyMutex *mutex = this_ethread()->mutex.get(); - int accept_threads = opt.accept_threads; // might be changed. - IpEndpoint accept_ip; // local binding address. - int listen_per_thread = 0; + int accept_threads = opt.accept_threads; // might be changed. + int listen_per_thread = 0; + IpEndpoint accept_ip; // local binding address. NetAccept *na = createNetAccept(opt); na->id = ink_atomic_increment(&net_accept_number, 1); @@ -99,7 +97,7 @@ UnixNetProcessor::accept_internal(Continuation *cont, int fd, AcceptOptions cons Fatal("Please disable accept_threads or exec_thread.listen"); } - NET_INCREMENT_DYN_STAT(net_accepts_currently_open_stat); + Metrics::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/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc index ee7fe8a93f2..c97fc70f97f 100644 --- a/iocore/net/UnixNetVConnection.cc +++ b/iocore/net/UnixNetVConnection.cc @@ -187,9 +187,8 @@ write_signal_error(NetHandler *nh, UnixNetVConnection *vc, int lerrno) static void read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) { - NetState *s = &vc->read; - ProxyMutex *mutex = thread->mutex.get(); - int64_t r = 0; + NetState *s = &vc->read; + int64_t r = 0; MUTEX_TRY_LOCK(lock, s->vio.mutex, thread); @@ -263,7 +262,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) msg.msg_iovlen = niov; r = SocketManager::recvmsg(vc->con.fd, &msg, 0); - NET_INCREMENT_DYN_STAT(net_calls_to_read_stat); + Metrics::increment(net_rsb.calls_to_read); total_read += rattempted; } while (rattempted && r == rattempted && total_read < toread); @@ -279,7 +278,7 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) // check for errors if (r <= 0) { if (r == -EAGAIN || r == -ENOTCONN) { - NET_INCREMENT_DYN_STAT(net_calls_to_read_nodata_stat); + Metrics::increment(net_rsb.calls_to_read_nodata); vc->read.triggered = 0; nh->read_ready_list.remove(vc); return; @@ -295,7 +294,8 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) read_signal_error(nh, vc, static_cast(-r)); return; } - NET_SUM_DYN_STAT(net_read_bytes_stat, r); + Metrics::increment(net_rsb.read_bytes, r); + Metrics::increment(net_rsb.read_bytes_count); // Add data to buffer and signal continuation. buf.writer()->fill(r); @@ -347,19 +347,15 @@ read_from_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) void write_to_net(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) { - ProxyMutex *mutex = thread->mutex.get(); - - NET_INCREMENT_DYN_STAT(net_calls_to_writetonet_stat); - + Metrics::increment(net_rsb.calls_to_writetonet); write_to_net_io(nh, vc, thread); } void write_to_net_io(NetHandler *nh, UnixNetVConnection *vc, EThread *thread) { - NetState *s = &vc->write; - ProxyMutex *mutex = thread->mutex.get(); - Continuation *c = vc->write.vio.cont; + NetState *s = &vc->write; + Continuation *c = vc->write.vio.cont; MUTEX_TRY_LOCK(lock, s->vio.mutex, thread); @@ -476,7 +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) { - NET_SUM_DYN_STAT(net_write_bytes_stat, total_written); + Metrics::increment(net_rsb.write_bytes, total_written); + Metrics::increment(net_rsb.write_bytes_count); s->vio.ndone += total_written; net_activity(vc, thread); } @@ -487,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) { - NET_INCREMENT_DYN_STAT(net_calls_to_write_nodata_stat); + Metrics::increment(net_rsb.calls_to_write_nodata); if ((needs & EVENTIO_WRITE) == EVENTIO_WRITE) { vc->write.triggered = 0; nh->write_ready_list.remove(vc); @@ -919,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) { - NET_INCREMENT_DYN_STAT(net_fastopen_attempts_stat); + Metrics::increment(net_rsb.fastopen_attempts); flags = MSG_FASTOPEN; } r = SocketManager::sendmsg(con.fd, &msg, flags); @@ -929,7 +926,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu this->con.is_connected = true; } } else { - NET_INCREMENT_DYN_STAT(net_fastopen_successes_stat); + Metrics::increment(net_rsb.fastopen_successes); this->con.is_connected = true; } } @@ -939,8 +936,7 @@ UnixNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu total_written += r; } - ProxyMutex *mutex = thread->mutex.get(); - NET_INCREMENT_DYN_STAT(net_calls_to_write_stat); + Metrics::increment(net_rsb.calls_to_write); } while (r == try_to_write && total_written < towrite); tmp_reader->dealloc(); @@ -1163,7 +1159,7 @@ UnixNetVConnection::connectUp(EThread *t, int fd) if (check_net_throttle(CONNECT)) { check_throttle_warning(CONNECT); res = -ENET_THROTTLING; - NET_INCREMENT_DYN_STAT(net_connections_throttled_out_stat); + Metrics::increment(net_rsb.connections_throttled_out); goto fail; } @@ -1216,7 +1212,7 @@ UnixNetVConnection::connectUp(EThread *t, int fd) } // Did not fail, increment connection count - NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1); + Metrics::increment(net_rsb.connections_currently_open); ink_release_assert(con.fd != NO_FD); // Setup a timeout callback handler. @@ -1292,7 +1288,7 @@ UnixNetVConnection::free_thread(EThread *t) // close socket fd if (con.fd != NO_FD) { - NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, -1); + Metrics::decrement(net_rsb.connections_currently_open); } con.close(); diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc index ff1f58bbfda..023fd88e470 100644 --- a/proxy/http/Http1ClientSession.cc +++ b/proxy/http/Http1ClientSession.cc @@ -118,7 +118,7 @@ Http1ClientSession::free() #endif if (conn_decrease) { - HTTP_DECREMENT_DYN_STAT(http_current_client_connections_stat); + Metrics::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; - HTTP_INCREMENT_DYN_STAT(http_current_client_connections_stat); + Metrics::increment(http_rsb.current_client_connections); conn_decrease = true; - HTTP_INCREMENT_DYN_STAT(http_total_client_connections_stat); + Metrics::increment(http_rsb.total_client_connections); if (static_cast(new_vc->attributes) == HttpProxyPort::TRANSPORT_SSL) { - HTTP_INCREMENT_DYN_STAT(https_total_client_connections_stat); + Metrics::increment(http_rsb.https_total_client_connections); } /* inbound requests stat should be incremented here, not after the * header has been read */ - HTTP_INCREMENT_DYN_STAT(http_total_incoming_connections_stat); + Metrics::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: - HTTP_INCREMENT_DYN_STAT(http_total_client_connections_ipv4_stat); + Metrics::increment(http_rsb.total_client_connections_ipv4); break; case AF_INET6: - HTTP_INCREMENT_DYN_STAT(http_total_client_connections_ipv6_stat); + Metrics::increment(http_rsb.total_client_connections_ipv6); break; default: // don't do anything if the address family is not ipv4 or ipv6 @@ -263,7 +263,6 @@ Http1ClientSession::do_io_close(int alerrno) _reader->consume(_reader->read_avail()); } else { HttpSsnDebug("[%" PRId64 "] session closed", con_id); - HTTP_SUM_DYN_STAT(http_transactions_per_client_con, transact_count); read_state = HCS_CLOSED; if (_vc) { @@ -514,12 +513,12 @@ Http1ClientSession::attach_server_session(PoolableSession *ssession, bool transa void Http1ClientSession::increment_current_active_connections_stat() { - HTTP_INCREMENT_DYN_STAT(http_current_active_client_connections_stat); + Metrics::increment(http_rsb.current_active_client_connections); } void Http1ClientSession::decrement_current_active_connections_stat() { - HTTP_DECREMENT_DYN_STAT(http_current_active_client_connections_stat); + Metrics::decrement(http_rsb.current_active_client_connections); } void diff --git a/proxy/http/Http1ClientTransaction.cc b/proxy/http/Http1ClientTransaction.cc index 3309063989b..320c3316886 100644 --- a/proxy/http/Http1ClientTransaction.cc +++ b/proxy/http/Http1ClientTransaction.cc @@ -59,11 +59,11 @@ Http1ClientTransaction::allow_half_open() const void Http1ClientTransaction::increment_transactions_stat() { - HTTP_INCREMENT_DYN_STAT(http_current_client_transactions_stat); + Metrics::increment(http_rsb.current_client_transactions); } void Http1ClientTransaction::decrement_transactions_stat() { - HTTP_DECREMENT_DYN_STAT(http_current_client_transactions_stat); + Metrics::decrement(http_rsb.current_client_transactions); } diff --git a/proxy/http/Http1ServerSession.cc b/proxy/http/Http1ServerSession.cc index eab2736e9ad..43f0b01b53a 100644 --- a/proxy/http/Http1ServerSession.cc +++ b/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; - HTTP_SUM_GLOBAL_DYN_STAT(http_current_server_connections_stat, 1); // Update the true global stat - HTTP_INCREMENT_DYN_STAT(http_total_server_connections_stat); + Metrics::increment(http_rsb.current_server_connections); + Metrics::increment(http_rsb.total_server_connections); if (iobuf == nullptr) { read_buffer = new_MIOBuffer(HTTP_SERVER_RESP_HDR_BUFFER_INDEX); @@ -110,8 +110,7 @@ Http1ServerSession::do_io_close(int alerrno) w.print("[{}] session close: nevtc {:x}", con_id, _vc); } - HTTP_SUM_GLOBAL_DYN_STAT(http_current_server_connections_stat, -1); // Make sure to work on the global stat - HTTP_SUM_DYN_STAT(http_transactions_per_server_con, transact_count); + Metrics::decrement(http_rsb.current_server_connections); // Update upstream connection tracking data if present. this->release_outbound_connection_tracking(); @@ -126,7 +125,7 @@ Http1ServerSession::do_io_close(int alerrno) _vc = nullptr; if (to_parent_proxy) { - HTTP_DECREMENT_DYN_STAT(http_current_parent_proxy_connections_stat); + Metrics::decrement(http_rsb.current_parent_proxy_connections); } } @@ -208,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()) { - HTTP_INCREMENT_DYN_STAT(http_origin_close_private); + Metrics::increment(http_rsb.origin_close_private); } this->do_io_close(); } else if (state == SSN_TO_RELEASE) { @@ -226,7 +225,7 @@ Http1ServerSession ::release_transaction() // due to lock contention // FIX: should retry instead of closing do_io_close(HTTP_ERRNO); - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_pool_lock_contention); + Metrics::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/proxy/http/Http1ServerTransaction.cc b/proxy/http/Http1ServerTransaction.cc index 55c48a77b59..68c5eea3a87 100644 --- a/proxy/http/Http1ServerTransaction.cc +++ b/proxy/http/Http1ServerTransaction.cc @@ -33,13 +33,13 @@ Http1ServerTransaction::release() void Http1ServerTransaction::increment_transactions_stat() { - HTTP_INCREMENT_DYN_STAT(http_current_server_transactions_stat); + Metrics::increment(http_rsb.current_server_transactions); } void Http1ServerTransaction::decrement_transactions_stat() { - HTTP_DECREMENT_DYN_STAT(http_current_server_transactions_stat); + Metrics::decrement(http_rsb.current_server_transactions); } void diff --git a/proxy/http/HttpCacheSM.cc b/proxy/http/HttpCacheSM.cc index 8fce8293485..c1255244afb 100644 --- a/proxy/http/HttpCacheSM.cc +++ b/proxy/http/HttpCacheSM.cc @@ -107,7 +107,7 @@ HttpCacheSM::state_cache_open_read(int event, void *data) switch (event) { case CACHE_EVENT_OPEN_READ: - HTTP_INCREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::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: - HTTP_INCREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::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/proxy/http/HttpCacheSM.h b/proxy/http/HttpCacheSM.h index cb330c027ae..3c77520c15a 100644 --- a/proxy/http/HttpCacheSM.h +++ b/proxy/http/HttpCacheSM.h @@ -160,7 +160,7 @@ class HttpCacheSM : public Continuation abort_read() { if (cache_read_vc) { - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::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) { - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::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) { - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::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) { - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::decrement(http_rsb.current_cache_connections); cache_read_vc->do_io_close(); cache_read_vc = nullptr; } diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index f5594657d12..6dfcc3dc73c 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -52,13 +52,6 @@ extern void HostDB_Config_Init(); REC_EstablishStaticConfigByte(_ix, _n); \ REC_RegisterConfigUpdateFunc(_n, http_config_cb, NULL) -RecRawStatBlock *http_rsb; -#define HTTP_CLEAR_DYN_STAT(x) \ - do { \ - RecSetRawStatSum(http_rsb, x, 0); \ - RecSetRawStatCount(http_rsb, x, 0); \ - } while (0); - class HttpConfigCont : public Continuation { public: @@ -303,786 +296,264 @@ http_insert_forwarded_cb(const char *name, RecDataT dtype, RecData data, void *c void register_stat_callbacks() { - // Dynamic stats - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.background_fill_current_count", RECD_INT, RECP_NON_PERSISTENT, - (int)http_background_fill_current_count_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_background_fill_current_count_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_client_connections", RECD_INT, RECP_NON_PERSISTENT, - (int)http_current_client_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_current_client_connections_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_active_client_connections", RECD_INT, RECP_NON_PERSISTENT, - (int)http_current_active_client_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_current_active_client_connections_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.websocket.current_active_client_connections", RECD_INT, - RECP_NON_PERSISTENT, (int)http_websocket_current_active_client_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_websocket_current_active_client_connections_stat); - - // Tunnel Stats - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.tunnel.current_active_connections", RECD_INT, RECP_NON_PERSISTENT, - (int)tunnel_current_active_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(tunnel_current_active_connections_stat); - - // Current Transaction Stats - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_client_transactions", RECD_INT, RECP_NON_PERSISTENT, - (int)http_current_client_transactions_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_current_client_transactions_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_server_transactions", RECD_INT, RECP_NON_PERSISTENT, - (int)http_current_server_transactions_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_current_server_transactions_stat); - // Total connections stats - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.completed_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_completed_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_incoming_connections", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_incoming_connections_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_client_connections", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_client_connections_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_client_connections_ipv4", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_client_connections_ipv4_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_client_connections_ipv6", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_client_connections_ipv6_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_server_connections", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_server_connections_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_parent_proxy_connections", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_parent_proxy_connections_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_parent_retries", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_parent_retries_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_parent_switches", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_parent_switches_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_parent_retries_exhausted", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_parent_retries_exhausted_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_parent_marked_down_count", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_parent_marked_down_count, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.background_fill_total_count", RECD_INT, RECP_PERSISTENT, - (int)http_background_fill_total_count_stat, RecRawStatSyncCount); - - // Stats to track causes of ATS initiated origin shutdowns - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.pool_lock_contention", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_pool_lock_contention, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.migration_failure", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_migration_failure, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_tunnel_server, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_no_keep_alive", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_server_no_keep_alive, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_eos", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_tunnel_server_eos, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_plugin_tunnel", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_server_plugin_tunnel, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_server_detach", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_server_detach, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_client", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_tunnel_client, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_transform_read", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_tunnel_transform_read, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_no_sharing", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_release_no_sharing, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_no_server", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_release_no_server, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_no_keep_alive", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_release_no_keep_alive, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_invalid_response", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_release_invalid_response, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_invalid_request", RECD_INT, - RECP_NON_PERSISTENT, (int)http_origin_shutdown_release_invalid_request, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_modified", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_release_modified, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.release_misc", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_release_misc, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.cleanup_entry", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_cleanup_entry, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_shutdown.tunnel_abort", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_shutdown_tunnel_abort, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.reuse", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_reuse, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.not_found", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_not_found, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.reuse_fail", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_reuse_fail, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.make_new", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_make_new, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.no_sharing", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_no_sharing, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.body", RECD_INT, RECP_NON_PERSISTENT, (int)http_origin_body, - RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.private", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_private, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.close_private", RECD_INT, RECP_NON_PERSISTENT, - (int)http_origin_close_private, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.raw", RECD_INT, RECP_NON_PERSISTENT, (int)http_origin_raw, - RecRawStatSyncCount); - - // Upstream current connections stats - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_parent_proxy_connections", RECD_INT, RECP_NON_PERSISTENT, - (int)http_current_parent_proxy_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_current_parent_proxy_connections_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_server_connections", RECD_INT, RECP_NON_PERSISTENT, - (int)http_current_server_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_current_server_connections_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.current_cache_connections", RECD_INT, RECP_NON_PERSISTENT, - (int)http_current_cache_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_current_cache_connections_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.avg_transactions_per_client_connection", RECD_FLOAT, - RECP_PERSISTENT, (int)http_transactions_per_client_con, RecRawStatSyncAvg); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.avg_transactions_per_server_connection", RECD_FLOAT, - RECP_PERSISTENT, (int)http_transactions_per_server_con, RecRawStatSyncAvg); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.errors.pre_accept_hangups", RECD_COUNTER, - RECP_PERSISTENT, (int)http_ua_msecs_counts_errors_pre_accept_hangups_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.errors.pre_accept_hangups", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_errors_pre_accept_hangups_stat, - RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.pooled_server_connections", RECD_INT, RECP_NON_PERSISTENT, - (int)http_pooled_server_connections_stat, RecRawStatSyncSum); - HTTP_CLEAR_DYN_STAT(http_pooled_server_connections_stat); - - // Transactional stats - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.incoming_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_incoming_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.outgoing_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_outgoing_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.incoming_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_incoming_responses_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.invalid_client_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_invalid_client_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.missing_host_hdr", RECD_COUNTER, RECP_PERSISTENT, - (int)http_missing_host_hdr_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.get_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_get_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.head_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_head_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.trace_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_trace_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.options_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_options_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.post_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_post_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.put_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_put_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.push_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_push_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.delete_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_delete_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.purge_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_purge_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.connect_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_connect_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.extension_method_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_extension_method_requests_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.http_proxy_loop_detected", RECD_COUNTER, RECP_PERSISTENT, - (int)http_proxy_loop_detected_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.http_proxy_mh_loop_detected", RECD_COUNTER, RECP_PERSISTENT, - (int)http_proxy_mh_loop_detected_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.broken_server_connections", RECD_COUNTER, RECP_PERSISTENT, - (int)http_broken_server_connections_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_lookups", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_lookups_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_writes", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_writes_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_updates", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_updates_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_deletes", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_deletes_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tunnels", RECD_COUNTER, RECP_PERSISTENT, (int)http_tunnels_stat, - RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.parent_proxy_transaction_time", RECD_INT, RECP_PERSISTENT, - (int)http_parent_proxy_transaction_time_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_request_header_total_size", RECD_INT, RECP_PERSISTENT, - (int)http_user_agent_request_header_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_response_header_total_size", RECD_INT, RECP_PERSISTENT, - (int)http_user_agent_response_header_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_request_document_total_size", RECD_INT, RECP_PERSISTENT, - (int)http_user_agent_request_document_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_response_document_total_size", RECD_INT, - RECP_PERSISTENT, (int)http_user_agent_response_document_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_request_header_total_size", RECD_INT, - RECP_PERSISTENT, (int)http_origin_server_request_header_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_response_header_total_size", RECD_INT, - RECP_PERSISTENT, (int)http_origin_server_response_header_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_request_document_total_size", RECD_INT, - RECP_PERSISTENT, (int)http_origin_server_request_document_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_response_document_total_size", RECD_INT, - RECP_PERSISTENT, (int)http_origin_server_response_document_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.parent_proxy_request_total_bytes", RECD_INT, RECP_PERSISTENT, - (int)http_parent_proxy_request_total_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.parent_proxy_response_total_bytes", RECD_INT, RECP_PERSISTENT, - (int)http_parent_proxy_response_total_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.pushed_response_header_total_size", RECD_INT, RECP_PERSISTENT, - (int)http_pushed_response_header_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.pushed_document_total_size", RECD_INT, RECP_PERSISTENT, - (int)http_pushed_document_total_size_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.response_document_size_100", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_document_size_100_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.response_document_size_1K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_document_size_1K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.response_document_size_3K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_document_size_3K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.response_document_size_5K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_document_size_5K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.response_document_size_10K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_document_size_10K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.response_document_size_1M", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_document_size_1M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.response_document_size_inf", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_document_size_inf_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.request_document_size_100", RECD_COUNTER, RECP_PERSISTENT, - (int)http_request_document_size_100_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.request_document_size_1K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_request_document_size_1K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.request_document_size_3K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_request_document_size_3K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.request_document_size_5K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_request_document_size_5K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.request_document_size_10K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_request_document_size_10K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.request_document_size_1M", RECD_COUNTER, RECP_PERSISTENT, - (int)http_request_document_size_1M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.request_document_size_inf", RECD_COUNTER, RECP_PERSISTENT, - (int)http_request_document_size_inf_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_speed_bytes_per_sec_100", RECD_COUNTER, RECP_PERSISTENT, - (int)http_user_agent_speed_bytes_per_sec_100_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_speed_bytes_per_sec_1K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_user_agent_speed_bytes_per_sec_1K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_speed_bytes_per_sec_10K", RECD_COUNTER, RECP_PERSISTENT, - (int)http_user_agent_speed_bytes_per_sec_10K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_speed_bytes_per_sec_100K", RECD_COUNTER, - RECP_PERSISTENT, (int)http_user_agent_speed_bytes_per_sec_100K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_speed_bytes_per_sec_1M", RECD_COUNTER, RECP_PERSISTENT, - (int)http_user_agent_speed_bytes_per_sec_1M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_speed_bytes_per_sec_10M", RECD_COUNTER, RECP_PERSISTENT, - (int)http_user_agent_speed_bytes_per_sec_10M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.user_agent_speed_bytes_per_sec_100M", RECD_COUNTER, - RECP_PERSISTENT, (int)http_user_agent_speed_bytes_per_sec_100M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_speed_bytes_per_sec_100", RECD_COUNTER, - RECP_PERSISTENT, (int)http_origin_server_speed_bytes_per_sec_100_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_speed_bytes_per_sec_1K", RECD_COUNTER, - RECP_PERSISTENT, (int)http_origin_server_speed_bytes_per_sec_1K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_speed_bytes_per_sec_10K", RECD_COUNTER, - RECP_PERSISTENT, (int)http_origin_server_speed_bytes_per_sec_10K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_speed_bytes_per_sec_100K", RECD_COUNTER, - RECP_PERSISTENT, (int)http_origin_server_speed_bytes_per_sec_100K_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_speed_bytes_per_sec_1M", RECD_COUNTER, - RECP_PERSISTENT, (int)http_origin_server_speed_bytes_per_sec_1M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_speed_bytes_per_sec_10M", RECD_COUNTER, - RECP_PERSISTENT, (int)http_origin_server_speed_bytes_per_sec_10M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_server_speed_bytes_per_sec_100M", RECD_COUNTER, - RECP_PERSISTENT, (int)http_origin_server_speed_bytes_per_sec_100M_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_transactions_time", RECD_INT, RECP_PERSISTENT, - (int)http_total_transactions_time_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_hit_fresh", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_hit_fresh_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_hit_mem_fresh", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_hit_mem_fresh_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_hit_rww", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_hit_rww_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_hit_revalidated", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_hit_reval_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_hit_ims", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_hit_ims_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_hit_stale_served", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_hit_stale_served_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_miss_cold", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_miss_cold_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_miss_changed", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_miss_changed_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_miss_client_no_cache", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_miss_client_no_cache_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_miss_client_not_cacheable", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_miss_uncacheable_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_miss_ims", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_miss_ims_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_read_error", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_read_error_stat, RecRawStatSyncCount); - - ///////////////////////////////////////// - // Bandwidth Savings Transaction Stats // - ///////////////////////////////////////// - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_hit_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_hit_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_hit_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_hit_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_hit_origin_server_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_hit_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_miss_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_miss_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_miss_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_miss_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_miss_origin_server_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_miss_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_expired_miss_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_expired_miss_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_expired_miss_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_expired_miss_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_expired_miss_origin_server_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_tcp_expired_miss_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_refresh_hit_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_refresh_hit_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_refresh_hit_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_refresh_hit_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_refresh_hit_origin_server_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_tcp_refresh_hit_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_refresh_miss_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_refresh_miss_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_refresh_miss_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_refresh_miss_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_refresh_miss_origin_server_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_tcp_refresh_miss_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_client_refresh_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_client_refresh_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_client_refresh_user_agent_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_tcp_client_refresh_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_client_refresh_origin_server_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_tcp_client_refresh_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_ims_hit_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_ims_hit_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_ims_hit_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_ims_hit_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_ims_hit_origin_server_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_ims_hit_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_ims_miss_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_tcp_ims_miss_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_ims_miss_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_ims_miss_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.tcp_ims_miss_origin_server_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_tcp_ims_miss_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_client_abort_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_err_client_abort_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_client_abort_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_err_client_abort_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_client_abort_origin_server_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_err_client_abort_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_client_read_error_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_err_client_read_error_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_client_read_error_user_agent_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_err_client_read_error_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_client_read_error_origin_server_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_err_client_read_error_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_connect_fail_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_err_connect_fail_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_connect_fail_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_err_connect_fail_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.err_connect_fail_origin_server_bytes_stat", RECD_INT, - RECP_PERSISTENT, (int)http_err_connect_fail_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.misc_count_stat", RECD_COUNTER, RECP_PERSISTENT, - (int)http_misc_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.misc_user_agent_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_misc_user_agent_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.http_misc_origin_server_bytes_stat", RECD_INT, RECP_PERSISTENT, - (int)http_misc_origin_server_bytes_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.background_fill_bytes_aborted_stat", RECD_INT, RECP_PERSISTENT, - (int)http_background_fill_bytes_aborted_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.background_fill_bytes_completed_stat", RECD_INT, RECP_PERSISTENT, - (int)http_background_fill_bytes_completed_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_write_errors", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_write_errors, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache_read_errors", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_read_errors, RecRawStatSyncSum); - - //////////////////////////////////////////////////////////////////////////////// - // status code counts - //////////////////////////////////////////////////////////////////////////////// - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.100_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_100_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.101_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_101_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.1xx_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_1xx_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.200_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_200_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.201_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_201_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.202_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_202_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.203_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_203_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.204_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_204_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.205_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_205_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.206_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_206_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.2xx_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_2xx_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.300_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_300_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.301_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_301_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.302_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_302_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.303_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_303_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.304_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_304_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.305_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_305_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.307_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_307_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.308_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_308_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.3xx_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_3xx_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.400_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_400_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.401_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_401_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.402_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_402_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.403_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_403_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.404_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_404_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.405_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_405_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.406_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_406_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.407_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_407_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.408_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_408_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.409_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_409_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.410_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_410_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.411_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_411_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.412_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_412_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.413_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_413_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.414_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_414_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.415_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_415_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.416_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_416_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.4xx_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_4xx_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.500_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_500_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.501_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_501_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.502_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_502_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.503_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_503_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.504_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_504_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.505_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_505_count_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.5xx_responses", RECD_COUNTER, RECP_PERSISTENT, - (int)http_response_status_5xx_count_stat, RecRawStatSyncCount); - - //////////////////////////////////////////////////////////////////////////////// - // http - time and count of transactions classified by client's point of view // - // the internal stat is in msecs, the output time is float seconds // - //////////////////////////////////////////////////////////////////////////////// - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.hit_fresh", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_msecs_counts_hit_fresh_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.hit_fresh", RECD_FLOAT, RECP_PERSISTENT, - (int)http_ua_msecs_counts_hit_fresh_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.hit_fresh.process", RECD_COUNTER, - RECP_PERSISTENT, (int)http_ua_msecs_counts_hit_fresh_process_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.hit_fresh.process", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_hit_fresh_process_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.hit_revalidated", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_msecs_counts_hit_reval_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.hit_revalidated", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_hit_reval_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.miss_cold", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_msecs_counts_miss_cold_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.miss_cold", RECD_FLOAT, RECP_PERSISTENT, - (int)http_ua_msecs_counts_miss_cold_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.miss_not_cacheable", RECD_COUNTER, - RECP_PERSISTENT, (int)http_ua_msecs_counts_miss_uncacheable_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.miss_not_cacheable", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_miss_uncacheable_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.miss_changed", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_msecs_counts_miss_changed_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.miss_changed", RECD_FLOAT, RECP_PERSISTENT, - (int)http_ua_msecs_counts_miss_changed_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.miss_client_no_cache", RECD_COUNTER, - RECP_PERSISTENT, (int)http_ua_msecs_counts_miss_client_no_cache_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.miss_client_no_cache", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_miss_client_no_cache_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.errors.aborts", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_msecs_counts_errors_aborts_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.errors.aborts", RECD_FLOAT, RECP_PERSISTENT, - (int)http_ua_msecs_counts_errors_aborts_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.errors.possible_aborts", RECD_COUNTER, - RECP_PERSISTENT, (int)http_ua_msecs_counts_errors_possible_aborts_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.errors.possible_aborts", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_errors_possible_aborts_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.errors.connect_failed", RECD_COUNTER, - RECP_PERSISTENT, (int)http_ua_msecs_counts_errors_connect_failed_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.errors.connect_failed", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_errors_connect_failed_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.errors.other", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_msecs_counts_errors_other_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.errors.other", RECD_FLOAT, RECP_PERSISTENT, - (int)http_ua_msecs_counts_errors_other_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_counts.other.unclassified", RECD_COUNTER, - RECP_PERSISTENT, (int)http_ua_msecs_counts_other_unclassified_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.transaction_totaltime.other.unclassified", RECD_FLOAT, - RECP_PERSISTENT, (int)http_ua_msecs_counts_other_unclassified_stat, RecRawStatSyncIntMsecsToFloatSeconds); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.disallowed_post_100_continue", RECD_COUNTER, RECP_PERSISTENT, - (int)disallowed_post_100_continue, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.total_x_redirect_count", RECD_COUNTER, RECP_PERSISTENT, - (int)http_total_x_redirect_stat, RecRawStatSyncCount); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.https.incoming_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)https_incoming_requests_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.https.total_client_connections", RECD_COUNTER, RECP_PERSISTENT, - (int)https_total_client_connections_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin_connections_throttled_out", RECD_COUNTER, RECP_PERSISTENT, - (int)http_origin_connections_throttled_stat, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.post_body_too_large", RECD_COUNTER, RECP_PERSISTENT, - (int)http_post_body_too_large, RecRawStatSyncCount); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.origin.connect.adjust_thread", RECD_COUNTER, RECP_NON_PERSISTENT, - (int)http_origin_connect_adjust_thread_stat, RecRawStatSyncCount); - HTTP_CLEAR_DYN_STAT(http_origin_connect_adjust_thread_stat); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.cache.open_write.adjust_thread", RECD_COUNTER, RECP_NON_PERSISTENT, - (int)http_cache_open_write_adjust_thread_stat, RecRawStatSyncCount); - HTTP_CLEAR_DYN_STAT(http_cache_open_write_adjust_thread_stat); - // milestones - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.ua_begin", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_begin_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.ua_first_read", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_first_read_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.ua_read_header_done", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_read_header_done_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.ua_begin_write", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_begin_write_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.ua_close", RECD_COUNTER, RECP_PERSISTENT, - (int)http_ua_close_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.server_first_connect", RECD_COUNTER, RECP_PERSISTENT, - (int)http_server_first_connect_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.server_connect", RECD_COUNTER, RECP_PERSISTENT, - (int)http_server_connect_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.server_connect_end", RECD_COUNTER, RECP_PERSISTENT, - (int)http_server_connect_end_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.server_begin_write", RECD_COUNTER, RECP_PERSISTENT, - (int)http_server_begin_write_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.server_first_read", RECD_COUNTER, RECP_PERSISTENT, - (int)http_server_first_read_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.server_read_header_done", RECD_COUNTER, RECP_PERSISTENT, - (int)http_server_read_header_done_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.server_close", RECD_COUNTER, RECP_PERSISTENT, - (int)http_server_close_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.cache_open_read_begin", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_open_read_begin_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.cache_open_read_end", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_open_read_end_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.cache_open_write_begin", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_open_write_begin_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.cache_open_write_end", RECD_COUNTER, RECP_PERSISTENT, - (int)http_cache_open_write_end_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.dns_lookup_begin", RECD_COUNTER, RECP_PERSISTENT, - (int)http_dns_lookup_begin_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.dns_lookup_end", RECD_COUNTER, RECP_PERSISTENT, - (int)http_dns_lookup_end_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.sm_start", RECD_COUNTER, RECP_PERSISTENT, - (int)http_sm_start_time_stat, RecRawStatSyncSum); - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.milestone.sm_finish", RECD_COUNTER, RECP_PERSISTENT, - (int)http_sm_finish_time_stat, RecRawStatSyncSum); - - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http.down_server.no_requests", RECD_COUNTER, RECP_PERSISTENT, - (int)http_down_server_no_requests, RecRawStatSyncSum); - - // Current transaction stats parent counter - RecRegisterRawStat(http_rsb, RECT_PROCESS, "proxy.process.http_parent_count", RECD_COUNTER, RECP_PERSISTENT, - (int)http_parent_count, RecRawStatSyncCount); + ts::Metrics &intm = ts::Metrics::getInstance(); + + http_rsb.background_fill_bytes_aborted = intm.newMetricPtr("proxy.process.http.background_fill_bytes_aborted_stat"); + http_rsb.background_fill_bytes_completed = intm.newMetricPtr("proxy.process.http.background_fill_bytes_completed_stat"); + 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_stat"); + http_rsb.err_client_abort_origin_server_bytes = intm.newMetricPtr("proxy.process.http.err_client_abort_origin_server_bytes_stat"); + http_rsb.err_client_abort_user_agent_bytes = intm.newMetricPtr("proxy.process.http.err_client_abort_user_agent_bytes_stat"); + http_rsb.err_client_read_error_count = intm.newMetricPtr("proxy.process.http.err_client_read_error_count_stat"); + http_rsb.err_client_read_error_origin_server_bytes = + intm.newMetricPtr("proxy.process.http.err_client_read_error_origin_server_bytes_stat"); + http_rsb.err_client_read_error_user_agent_bytes = + intm.newMetricPtr("proxy.process.http.err_client_read_error_user_agent_bytes_stat"); + http_rsb.err_connect_fail_count = intm.newMetricPtr("proxy.process.http.err_connect_fail_count_stat"); + http_rsb.err_connect_fail_origin_server_bytes = intm.newMetricPtr("proxy.process.http.err_connect_fail_origin_server_bytes_stat"); + http_rsb.err_connect_fail_user_agent_bytes = intm.newMetricPtr("proxy.process.http.err_connect_fail_user_agent_bytes_stat"); + 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_stat"); + http_rsb.misc_origin_server_bytes = intm.newMetricPtr("proxy.process.http.http_misc_origin_server_bytes_stat"); + http_rsb.misc_user_agent_bytes = intm.newMetricPtr("proxy.process.http.misc_user_agent_bytes_stat"); + 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"); + http_rsb.origin_server_request_document_total_size = + intm.newMetricPtr("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"); + http_rsb.origin_server_response_document_total_size = + intm.newMetricPtr("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"); + http_rsb.origin_shutdown_release_invalid_request = + intm.newMetricPtr("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"); + http_rsb.origin_shutdown_tunnel_server_no_keep_alive = + intm.newMetricPtr("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_stat"); + http_rsb.tcp_client_refresh_origin_server_bytes = + intm.newMetricPtr("proxy.process.http.tcp_client_refresh_origin_server_bytes_stat"); + http_rsb.tcp_client_refresh_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_client_refresh_user_agent_bytes_stat"); + http_rsb.tcp_expired_miss_count = intm.newMetricPtr("proxy.process.http.tcp_expired_miss_count_stat"); + http_rsb.tcp_expired_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_expired_miss_origin_server_bytes_stat"); + http_rsb.tcp_expired_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_expired_miss_user_agent_bytes_stat"); + http_rsb.tcp_hit_count = intm.newMetricPtr("proxy.process.http.tcp_hit_count_stat"); + http_rsb.tcp_hit_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_hit_origin_server_bytes_stat"); + http_rsb.tcp_hit_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_hit_user_agent_bytes_stat"); + http_rsb.tcp_ims_hit_count = intm.newMetricPtr("proxy.process.http.tcp_ims_hit_count_stat"); + http_rsb.tcp_ims_hit_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_hit_origin_server_bytes_stat"); + http_rsb.tcp_ims_hit_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_hit_user_agent_bytes_stat"); + http_rsb.tcp_ims_miss_count = intm.newMetricPtr("proxy.process.http.tcp_ims_miss_count_stat"); + http_rsb.tcp_ims_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_miss_origin_server_bytes_stat"); + http_rsb.tcp_ims_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_ims_miss_user_agent_bytes_stat"); + http_rsb.tcp_miss_count = intm.newMetricPtr("proxy.process.http.tcp_miss_count_stat"); + http_rsb.tcp_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_miss_origin_server_bytes_stat"); + http_rsb.tcp_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_miss_user_agent_bytes_stat"); + http_rsb.tcp_refresh_hit_count = intm.newMetricPtr("proxy.process.http.tcp_refresh_hit_count_stat"); + http_rsb.tcp_refresh_hit_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_hit_origin_server_bytes_stat"); + http_rsb.tcp_refresh_hit_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_hit_user_agent_bytes_stat"); + http_rsb.tcp_refresh_miss_count = intm.newMetricPtr("proxy.process.http.tcp_refresh_miss_count_stat"); + http_rsb.tcp_refresh_miss_origin_server_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_miss_origin_server_bytes_stat"); + http_rsb.tcp_refresh_miss_user_agent_bytes = intm.newMetricPtr("proxy.process.http.tcp_refresh_miss_user_agent_bytes_stat"); + 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"); + 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"); + 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"); + 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"); + http_rsb.websocket_current_active_client_connections = + intm.newMetricPtr("proxy.process.http.websocket.current_active_client_connections"); } static bool @@ -1140,11 +611,12 @@ load_negative_caching_var(RecRecord const *r, void *cookie) // HttpConfig::startup() // //////////////////////////////////////////////////////////////// +HttpStatsBlock http_rsb; + void HttpConfig::startup() { extern void SSLConfigInit(swoc::IPRangeSet * addrs); - http_rsb = RecAllocateRawStatBlock(static_cast(http_stat_count)); register_stat_callbacks(); HttpConfigParams &c = m_master; diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index c7d728c81c9..d4a535b32b9 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -53,6 +53,9 @@ #include "records/I_RecProcess.h" #include "HttpConnectionCount.h" #include "tscpp/util/ts_ip.h" +#include "api/Metrics.h" + +using ts::Metrics; static const unsigned HTTP_STATUS_NUMBER = 600; using HttpStatusBitset = std::bitset; @@ -60,315 +63,249 @@ using HttpStatusBitset = std::bitset; /* Instead of enumerating the stats in DynamicStats.h, each module needs to enumerate its stats separately and register them with librecords */ -enum { - http_background_fill_current_count_stat, - http_current_client_connections_stat, - http_current_active_client_connections_stat, - http_websocket_current_active_client_connections_stat, - tunnel_current_active_connections_stat, - http_current_client_transactions_stat, - http_total_incoming_connections_stat, - http_current_server_transactions_stat, - http_pooled_server_connections_stat, - - // Http Abort information (from HttpNetConnection) - http_ua_msecs_counts_errors_pre_accept_hangups_stat, - - // Http Total Connections Stats - // - // it is assumed that this inequality will always be satisfied: - // http_total_client_connections_stat >= - // http_total_client_connections_ipv4_stat + - // http_total_client_connections_ipv6_stat - http_total_client_connections_stat, - http_total_client_connections_ipv4_stat, - http_total_client_connections_ipv6_stat, - http_total_server_connections_stat, - http_total_parent_proxy_connections_stat, - http_total_parent_retries_stat, - http_total_parent_switches_stat, - http_total_parent_retries_exhausted_stat, - http_total_parent_marked_down_count, - http_background_fill_total_count_stat, - http_current_parent_proxy_connections_stat, - http_current_server_connections_stat, - http_current_cache_connections_stat, - - // Http K-A Stats - http_transactions_per_client_con, - http_transactions_per_server_con, - - // Transactional stats - http_incoming_requests_stat, - http_outgoing_requests_stat, - http_incoming_responses_stat, - http_invalid_client_requests_stat, - http_missing_host_hdr_stat, - http_get_requests_stat, - http_head_requests_stat, - http_trace_requests_stat, - http_options_requests_stat, - http_post_requests_stat, - http_put_requests_stat, - http_push_requests_stat, - http_delete_requests_stat, - http_purge_requests_stat, - http_connect_requests_stat, - http_extension_method_requests_stat, - http_proxy_loop_detected_stat, - http_proxy_mh_loop_detected_stat, - - http_completed_requests_stat, - http_broken_server_connections_stat, - - http_cache_lookups_stat, - http_cache_writes_stat, - http_cache_updates_stat, - http_cache_deletes_stat, - - http_tunnels_stat, - - // document size stats - http_user_agent_request_header_total_size_stat, - http_user_agent_response_header_total_size_stat, - http_user_agent_request_document_total_size_stat, - http_user_agent_response_document_total_size_stat, - - http_origin_server_request_header_total_size_stat, - http_origin_server_response_header_total_size_stat, - http_origin_server_request_document_total_size_stat, - http_origin_server_response_document_total_size_stat, - - http_parent_proxy_request_total_bytes_stat, - http_parent_proxy_response_total_bytes_stat, - - http_pushed_response_header_total_size_stat, - http_pushed_document_total_size_stat, - - http_background_fill_bytes_aborted_stat, - http_background_fill_bytes_completed_stat, - - http_response_document_size_100_stat, - http_response_document_size_1K_stat, - http_response_document_size_3K_stat, - http_response_document_size_5K_stat, - http_response_document_size_10K_stat, - http_response_document_size_1M_stat, - http_response_document_size_inf_stat, - - http_request_document_size_100_stat, - http_request_document_size_1K_stat, - http_request_document_size_3K_stat, - http_request_document_size_5K_stat, - http_request_document_size_10K_stat, - http_request_document_size_1M_stat, - http_request_document_size_inf_stat, - - // connection speed stats - http_user_agent_speed_bytes_per_sec_100_stat, - http_user_agent_speed_bytes_per_sec_1K_stat, - http_user_agent_speed_bytes_per_sec_10K_stat, - http_user_agent_speed_bytes_per_sec_100K_stat, - http_user_agent_speed_bytes_per_sec_1M_stat, - http_user_agent_speed_bytes_per_sec_10M_stat, - http_user_agent_speed_bytes_per_sec_100M_stat, - http_origin_server_speed_bytes_per_sec_100_stat, - http_origin_server_speed_bytes_per_sec_1K_stat, - http_origin_server_speed_bytes_per_sec_10K_stat, - http_origin_server_speed_bytes_per_sec_100K_stat, - http_origin_server_speed_bytes_per_sec_1M_stat, - http_origin_server_speed_bytes_per_sec_10M_stat, - http_origin_server_speed_bytes_per_sec_100M_stat, - - // cache result stats - http_cache_hit_fresh_stat, - http_cache_hit_mem_fresh_stat, - http_cache_hit_rww_stat, - http_cache_hit_reval_stat, - http_cache_hit_ims_stat, - http_cache_hit_stale_served_stat, - http_cache_miss_cold_stat, - http_cache_miss_changed_stat, - http_cache_miss_client_no_cache_stat, - http_cache_miss_uncacheable_stat, - http_cache_miss_ims_stat, - http_cache_read_error_stat, - - // bandwidth savings stats - http_tcp_hit_count_stat, - http_tcp_hit_user_agent_bytes_stat, - http_tcp_hit_origin_server_bytes_stat, - http_tcp_miss_count_stat, - http_tcp_miss_user_agent_bytes_stat, - http_tcp_miss_origin_server_bytes_stat, - http_tcp_expired_miss_count_stat, - http_tcp_expired_miss_user_agent_bytes_stat, - http_tcp_expired_miss_origin_server_bytes_stat, - http_tcp_refresh_hit_count_stat, - http_tcp_refresh_hit_user_agent_bytes_stat, - http_tcp_refresh_hit_origin_server_bytes_stat, - http_tcp_refresh_miss_count_stat, - http_tcp_refresh_miss_user_agent_bytes_stat, - http_tcp_refresh_miss_origin_server_bytes_stat, - http_tcp_client_refresh_count_stat, - http_tcp_client_refresh_user_agent_bytes_stat, - http_tcp_client_refresh_origin_server_bytes_stat, - http_tcp_ims_hit_count_stat, - http_tcp_ims_hit_user_agent_bytes_stat, - http_tcp_ims_hit_origin_server_bytes_stat, - http_tcp_ims_miss_count_stat, - http_tcp_ims_miss_user_agent_bytes_stat, - http_tcp_ims_miss_origin_server_bytes_stat, - http_err_client_abort_count_stat, - http_err_client_abort_user_agent_bytes_stat, - http_err_client_abort_origin_server_bytes_stat, - http_err_client_read_error_count_stat, - http_err_client_read_error_user_agent_bytes_stat, - http_err_client_read_error_origin_server_bytes_stat, - http_err_connect_fail_count_stat, - http_err_connect_fail_user_agent_bytes_stat, - http_err_connect_fail_origin_server_bytes_stat, - http_misc_count_stat, - http_misc_user_agent_bytes_stat, - http_misc_origin_server_bytes_stat, - - // http - time and count of transactions classified by client's point of view - http_ua_msecs_counts_hit_fresh_stat, - - http_ua_msecs_counts_hit_fresh_process_stat, - http_ua_msecs_counts_hit_reval_stat, - http_ua_msecs_counts_miss_cold_stat, - http_ua_msecs_counts_miss_changed_stat, - http_ua_msecs_counts_miss_client_no_cache_stat, - http_ua_msecs_counts_miss_uncacheable_stat, - http_ua_msecs_counts_errors_aborts_stat, - http_ua_msecs_counts_errors_possible_aborts_stat, - http_ua_msecs_counts_errors_connect_failed_stat, - http_ua_msecs_counts_errors_other_stat, - http_ua_msecs_counts_other_unclassified_stat, - - disallowed_post_100_continue, - http_post_body_too_large, - - http_total_x_redirect_stat, - - // Times - http_total_transactions_time_stat, - http_parent_proxy_transaction_time_stat, - - // Http cache errors - http_cache_write_errors, - http_cache_read_errors, - - // status code stats - http_response_status_100_count_stat, - http_response_status_101_count_stat, - http_response_status_1xx_count_stat, - http_response_status_200_count_stat, - http_response_status_201_count_stat, - http_response_status_202_count_stat, - http_response_status_203_count_stat, - http_response_status_204_count_stat, - http_response_status_205_count_stat, - http_response_status_206_count_stat, - http_response_status_2xx_count_stat, - http_response_status_300_count_stat, - http_response_status_301_count_stat, - http_response_status_302_count_stat, - http_response_status_303_count_stat, - http_response_status_304_count_stat, - http_response_status_305_count_stat, - http_response_status_307_count_stat, - http_response_status_308_count_stat, - http_response_status_3xx_count_stat, - http_response_status_400_count_stat, - http_response_status_401_count_stat, - http_response_status_402_count_stat, - http_response_status_403_count_stat, - http_response_status_404_count_stat, - http_response_status_405_count_stat, - http_response_status_406_count_stat, - http_response_status_407_count_stat, - http_response_status_408_count_stat, - http_response_status_409_count_stat, - http_response_status_410_count_stat, - http_response_status_411_count_stat, - http_response_status_412_count_stat, - http_response_status_413_count_stat, - http_response_status_414_count_stat, - http_response_status_415_count_stat, - http_response_status_416_count_stat, - http_response_status_4xx_count_stat, - http_response_status_500_count_stat, - http_response_status_501_count_stat, - http_response_status_502_count_stat, - http_response_status_503_count_stat, - http_response_status_504_count_stat, - http_response_status_505_count_stat, - http_response_status_5xx_count_stat, - - https_incoming_requests_stat, - https_total_client_connections_stat, - - // milestone timing statistics in milliseconds - http_ua_begin_time_stat, - http_ua_first_read_time_stat, - http_ua_read_header_done_time_stat, - http_ua_begin_write_time_stat, - http_ua_close_time_stat, - http_server_first_connect_time_stat, - http_server_connect_time_stat, - http_server_connect_end_time_stat, - http_server_begin_write_time_stat, - http_server_first_read_time_stat, - http_server_read_header_done_time_stat, - http_server_close_time_stat, - http_cache_open_read_begin_time_stat, - http_cache_open_read_end_time_stat, - http_cache_open_write_begin_time_stat, - http_cache_open_write_end_time_stat, - http_dns_lookup_begin_time_stat, - http_dns_lookup_end_time_stat, - http_sm_start_time_stat, - http_sm_finish_time_stat, - - http_origin_connections_throttled_stat, - - http_origin_connect_adjust_thread_stat, - http_cache_open_write_adjust_thread_stat, - - http_origin_shutdown_pool_lock_contention, - http_origin_shutdown_migration_failure, - http_origin_shutdown_tunnel_server, - http_origin_shutdown_tunnel_server_no_keep_alive, - http_origin_shutdown_tunnel_server_eos, - http_origin_shutdown_tunnel_server_plugin_tunnel, - http_origin_shutdown_tunnel_server_detach, - http_origin_shutdown_tunnel_client, - http_origin_shutdown_tunnel_transform_read, - http_origin_shutdown_release_no_sharing, - http_origin_shutdown_release_no_server, - http_origin_shutdown_release_no_keep_alive, - http_origin_shutdown_release_invalid_response, - http_origin_shutdown_release_invalid_request, - http_origin_shutdown_release_modified, - http_origin_shutdown_release_misc, - http_origin_shutdown_cleanup_entry, - http_origin_shutdown_tunnel_abort, - - http_down_server_no_requests, - - http_origin_reuse, - http_origin_not_found, - http_origin_reuse_fail, - http_origin_make_new, - http_origin_no_sharing, - http_origin_body, - http_origin_private, - http_origin_close_private, - http_origin_raw, - http_parent_count, - http_stat_count +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; }; enum CacheOpenWriteFailAction_t { @@ -381,22 +318,7 @@ enum CacheOpenWriteFailAction_t { TOTAL_CACHE_WL_FAIL_ACTION_TYPES }; -extern RecRawStatBlock *http_rsb; - -/* Stats should only be accessed using these macros */ -#define HTTP_INCREMENT_DYN_STAT(x) RecIncrRawStat(http_rsb, this_ethread(), (int)x, 1) -#define HTTP_DECREMENT_DYN_STAT(x) RecIncrRawStat(http_rsb, this_ethread(), (int)x, -1) -#define HTTP_SUM_DYN_STAT(x, y) RecIncrRawStat(http_rsb, this_ethread(), (int)x, (int64_t)y) -#define HTTP_SUM_GLOBAL_DYN_STAT(x, y) RecIncrGlobalRawStatSum(http_rsb, x, y) - -#define HTTP_CLEAR_DYN_STAT(x) \ - do { \ - RecSetRawStatSum(http_rsb, x, 0); \ - RecSetRawStatCount(http_rsb, x, 0); \ - } while (0); - -#define HTTP_READ_DYN_SUM(x, S) RecGetRawStatSum(http_rsb, (int)x, &S) // This aggregates threads too -#define HTTP_READ_GLOBAL_DYN_SUM(x, S) RecGetGlobalRawStatSum(http_rsb, (int)x, &S) +extern HttpStatsBlock http_rsb; ///////////////////////////////////////////////////////////// // diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index de14655bf99..44c14d745ee 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -1603,7 +1603,7 @@ HttpSM::handle_api_return() // a blind tunnel. IOBufferReader *initial_data = nullptr; if (t_state.is_websocket) { - HTTP_INCREMENT_DYN_STAT(http_websocket_current_active_client_connections_stat); + Metrics::increment(http_rsb.websocket_current_active_client_connections); if (server_txn) { initial_data = server_txn->get_remote_reader(); } @@ -1720,8 +1720,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; - HTTP_INCREMENT_DYN_STAT(http_current_parent_proxy_connections_stat); - HTTP_INCREMENT_DYN_STAT(http_total_parent_proxy_connections_stat); + Metrics::increment(http_rsb.current_parent_proxy_connections); + Metrics::increment(http_rsb.total_parent_proxy_connections); } else { new_session->to_parent_proxy = false; } @@ -1841,7 +1841,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) { - HTTP_INCREMENT_DYN_STAT(http_origin_connections_throttled_stat); + Metrics::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 @@ -2454,7 +2454,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()) { - HTTP_INCREMENT_DYN_STAT(http_cache_open_write_adjust_thread_stat); + Metrics::increment(http_rsb.cache_open_write_adjust_thread); return 0; // Go away if we reschedule } NetVConnection *vc = _ua.get_txn()->get_netvc(); @@ -3006,7 +3006,7 @@ HttpSM::tunnel_handler(int event, void *data) terminate_sm = true; if (unlikely(t_state.is_websocket)) { - HTTP_DECREMENT_DYN_STAT(http_websocket_current_active_client_connections_stat); + Metrics::decrement(http_rsb.websocket_current_active_client_connections); } return 0; @@ -3067,11 +3067,11 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) close_connection = false; } else { if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_no_keep_alive); + Metrics::increment(http_rsb.origin_shutdown_tunnel_server_no_keep_alive); } else if (server_entry->eos == true) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_eos); + Metrics::increment(http_rsb.origin_shutdown_tunnel_server_eos); } else { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_plugin_tunnel); + Metrics::increment(http_rsb.origin_shutdown_tunnel_server_plugin_tunnel); } close_connection = true; } @@ -3100,7 +3100,7 @@ HttpSM::tunnel_handler_server(int event, HttpTunnelProducer *p) t_state.current.server->state = HttpTransact::TRANSACTION_COMPLETE; break; } - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server); + Metrics::increment(http_rsb.origin_shutdown_tunnel_server); close_connection = true; ink_assert(p->vc_type == HT_HTTP_SERVER); @@ -3178,7 +3178,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; - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_server_detach); + Metrics::increment(http_rsb.origin_shutdown_tunnel_server_detach); close_connection = true; break; @@ -3199,7 +3199,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; - HTTP_DECREMENT_DYN_STAT(http_background_fill_current_count_stat); + Metrics::decrement(http_rsb.background_fill_current_count); } // We handled the event. Now either shutdown the connection or // setup it up for keep-alive @@ -3446,8 +3446,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) { - HTTP_INCREMENT_DYN_STAT(http_background_fill_current_count_stat); - HTTP_INCREMENT_DYN_STAT(http_background_fill_total_count_stat); + Metrics::increment(http_rsb.background_fill_current_count); + Metrics::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)); @@ -3664,7 +3664,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); - HTTP_INCREMENT_DYN_STAT(http_cache_read_errors); + Metrics::increment(http_rsb.cache_read_errors); break; } else { tunnel.local_finish_all(p); @@ -3685,7 +3685,7 @@ HttpSM::tunnel_handler_cache_read(int event, HttpTunnelProducer *p) break; } - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::decrement(http_rsb.current_cache_connections); return 0; } @@ -3706,7 +3706,7 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c) c->write_vio = nullptr; c->vc->do_io_close(EHTTP_ERROR); - HTTP_INCREMENT_DYN_STAT(http_cache_write_errors); + Metrics::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) { @@ -3740,7 +3740,7 @@ HttpSM::tunnel_handler_cache_write(int event, HttpTunnelConsumer *c) server_response_body_bytes = c->bytes_written; } - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::decrement(http_rsb.current_cache_connections); return 0; } @@ -4231,7 +4231,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) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_transform_read); + Metrics::increment(http_rsb.origin_shutdown_tunnel_transform_read); p->vc->do_io_close(); } p->handler_state = HTTP_SM_TRANSFORM_CLOSED; @@ -4934,7 +4934,7 @@ HttpSM::do_cache_lookup_and_read() t_state.request_sent_time = UNDEFINED_TIME; t_state.response_received_time = UNDEFINED_TIME; - HTTP_INCREMENT_DYN_STAT(http_cache_lookups_stat); + Metrics::increment(http_rsb.cache_lookups); milestones[TS_MILESTONE_CACHE_OPEN_READ_BEGIN] = ink_get_hrtime(); t_state.cache_lookup_result = HttpTransact::CACHE_LOOKUP_NONE; @@ -5382,16 +5382,16 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) switch (shared_result) { case HSM_DONE: - HTTP_INCREMENT_DYN_STAT(http_origin_reuse); + Metrics::increment(http_rsb.origin_reuse); hsm_release_assert(server_txn != nullptr); handle_http_server_open(); return; case HSM_NOT_FOUND: - HTTP_INCREMENT_DYN_STAT(http_origin_not_found); + Metrics::increment(http_rsb.origin_not_found); hsm_release_assert(server_txn == nullptr); break; case HSM_RETRY: - HTTP_INCREMENT_DYN_STAT(http_origin_reuse_fail); + Metrics::increment(http_rsb.origin_reuse_fail); // Could not get shared pool lock // FIX: should retry lock break; @@ -5439,15 +5439,15 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) } if (!try_reuse) { - HTTP_INCREMENT_DYN_STAT(http_origin_make_new); + Metrics::increment(http_rsb.origin_make_new); if (TS_SERVER_SESSION_SHARING_MATCH_NONE == t_state.txn_conf->server_session_sharing_match) { - HTTP_INCREMENT_DYN_STAT(http_origin_no_sharing); + Metrics::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)) { - HTTP_INCREMENT_DYN_STAT(http_origin_body); + Metrics::increment(http_rsb.origin_body); } else if (is_private()) { - HTTP_INCREMENT_DYN_STAT(http_origin_private); + Metrics::increment(http_rsb.origin_private); } else if (raw) { - HTTP_INCREMENT_DYN_STAT(http_origin_raw); + Metrics::increment(http_rsb.origin_raw); } else { ink_release_assert(_ua.get_txn() == nullptr); } @@ -5468,15 +5468,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) { - int64_t sum; - - HTTP_READ_GLOBAL_DYN_SUM(http_current_server_connections_stat, sum); - - // Note that there is a potential race condition here where - // the value of the http_current_server_connections_stat gets changed - // between the statement above and the check below. - // If this happens, we might go over the max by 1 but this is ok. - if (sum >= t_state.http_config_param->server_max_connections) { + if (Metrics::read(http_rsb.current_server_connections) >= t_state.http_config_param->server_max_connections) { httpSessionManager.purge_keepalives(); // Eventually may want to have a queue as the origin_max_connection does to allow for a combination // of retries and errors. But at this point, we are just going to allow the error case. @@ -5502,7 +5494,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(); - HTTP_INCREMENT_DYN_STAT(http_origin_connections_throttled_stat); + Metrics::increment(http_rsb.origin_connections_throttled); ct_state.Warn_Blocked(&t_state.txn_conf->outbound_conntrack, sm_id, ccount - 1, &t_state.current.server->dst_addr.sa, debug_on && is_debug_tag_set("http") ? "http" : nullptr); send_origin_throttled_response(); @@ -5881,21 +5873,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) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_sharing); + Metrics::increment(http_rsb.origin_shutdown_release_no_sharing); } else if (t_state.current.server == nullptr) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_server); + Metrics::increment(http_rsb.origin_shutdown_release_no_server); } else if (t_state.current.server->keep_alive != HTTP_KEEPALIVE) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_no_keep_alive); + Metrics::increment(http_rsb.origin_shutdown_release_no_keep_alive); } else if (!t_state.hdr_info.server_response.valid()) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_invalid_response); + Metrics::increment(http_rsb.origin_shutdown_release_invalid_response); } else if (!t_state.hdr_info.server_request.valid()) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_invalid_request); + Metrics::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)) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_modified); + Metrics::increment(http_rsb.origin_shutdown_release_modified); } else { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_release_misc); + Metrics::increment(http_rsb.origin_shutdown_release_misc); } } @@ -8233,7 +8225,7 @@ HttpSM::do_redirect() ats_free((void *)redirect_url); redirect_url = nullptr; redirect_url_len = 0; - HTTP_INCREMENT_DYN_STAT(http_total_x_redirect_stat); + Metrics::increment(http_rsb.total_x_redirect); } else { // get the location header and setup the redirect int redir_len = 0; diff --git a/proxy/http/HttpSessionAccept.cc b/proxy/http/HttpSessionAccept.cc index c7a1cb2a1d8..278efe25af9 100644 --- a/proxy/http/HttpSessionAccept.cc +++ b/proxy/http/HttpSessionAccept.cc @@ -81,7 +81,8 @@ HttpSessionAccept::mainEvent(int event, void *data) ///////////////// if (((long)data) == -ECONNABORTED) { // FIX: add time to user_agent_hangup - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_pre_accept_hangups_stat, 0); + 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 } ink_abort("HTTP accept received fatal error: errno = %d", -(static_cast((intptr_t)data))); diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc index 09aeb8d73e0..5d3745d8b89 100644 --- a/proxy/http/HttpSessionManager.cc +++ b/proxy/http/HttpSessionManager.cc @@ -423,7 +423,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 - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_migration_failure); + Metrics::increment(http_rsb.origin_shutdown_migration_failure); to_return->do_io_close(); to_return = nullptr; retval = HSM_NOT_FOUND; @@ -500,7 +500,7 @@ ServerSessionPool::removeSession(PoolableSession *to_remove) } m_fqdn_pool.erase(to_remove); if (m_ip_pool.erase(to_remove)) { - HTTP_DECREMENT_DYN_STAT(http_pooled_server_connections_stat); + Metrics::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(), @@ -516,7 +516,7 @@ ServerSessionPool::addSession(PoolableSession *ss) // put it in the pools. m_ip_pool.insert(ss); m_fqdn_pool.insert(ss); - HTTP_INCREMENT_DYN_STAT(http_pooled_server_connections_stat); + Metrics::increment(http_rsb.pooled_server_connections); if (is_debug_tag_set("http_ss")) { char peer_ip[INET6_ADDRPORTSTRLEN]; diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index f379b16b5b6..0e5c9562c91 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -189,7 +189,7 @@ inline static void findParent(HttpTransact::State *s) { url_mapping *mp = s->url_map.getMapping(); - HTTP_INCREMENT_DYN_STAT(http_parent_count); + Metrics::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) { - HTTP_INCREMENT_DYN_STAT(http_total_parent_marked_down_count); + Metrics::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(); - HTTP_INCREMENT_DYN_STAT(http_parent_count); + Metrics::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; @@ -910,7 +910,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"); - HTTP_INCREMENT_DYN_STAT(http_down_server_no_requests); + Metrics::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); @@ -1195,7 +1195,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"); - HTTP_INCREMENT_DYN_STAT(http_invalid_client_requests_stat); + Metrics::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. @@ -1490,10 +1490,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()); - HTTP_INCREMENT_DYN_STAT(http_incoming_requests_stat); + Metrics::increment(http_rsb.incoming_requests); if (s->client_info.port_attribute == HttpProxyPort::TRANSPORT_SSL) { - HTTP_INCREMENT_DYN_STAT(https_incoming_requests_stat); + Metrics::increment(http_rsb.https_incoming_requests); } /////////////////////////////////////////////// @@ -1501,7 +1501,7 @@ HttpTransact::HandleRequest(State *s) /////////////////////////////////////////////// if (!(is_request_valid(s, &s->hdr_info.client_request))) { - HTTP_INCREMENT_DYN_STAT(http_invalid_client_requests_stat); + Metrics::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; @@ -1518,9 +1518,7 @@ HttpTransact::HandleRequest(State *s) initialize_state_variables_from_request(s, &s->hdr_info.client_request); // The following chunk of code will limit the maximum number of websocket connections (TS-3659) if (s->is_upgrade_request && s->is_websocket && s->http_config_param->max_websocket_connections >= 0) { - int64_t val = 0; - HTTP_READ_DYN_SUM(http_websocket_current_active_client_connections_stat, val); - if (val >= s->http_config_param->max_websocket_connections) { + if (Metrics::read(http_rsb.websocket_current_active_client_connections) >= s->http_config_param->max_websocket_connections) { s->is_websocket = false; // unset to avoid screwing up stats. TxnDebug("http_trans", "Rejecting websocket connection because the limit has been exceeded"); bootstrap_state_variables_from_request(s, &s->hdr_info.client_request); @@ -1534,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); - HTTP_INCREMENT_DYN_STAT(http_post_body_too_large); + Metrics::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; @@ -1552,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."); - HTTP_INCREMENT_DYN_STAT(disallowed_post_100_continue); + Metrics::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); } @@ -1682,7 +1680,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; - HTTP_INCREMENT_DYN_STAT(http_tunnels_stat); + Metrics::increment(http_rsb.tunnels); } // Regardless of the protocol we're gatewaying to // we see the scheme as http @@ -2097,7 +2095,7 @@ HttpTransact::DecideCacheLookup(State *s) } else { s->cache_info.action = CACHE_DO_NO_ACTION; s->current.mode = TUNNELLING_PROXY; - HTTP_INCREMENT_DYN_STAT(http_tunnels_stat); + Metrics::increment(http_rsb.tunnels); } } @@ -3428,7 +3426,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"); - HTTP_INCREMENT_DYN_STAT(http_incoming_responses_stat); + Metrics::increment(http_rsb.incoming_responses); ink_release_assert(s->current.request_to != ResolveInfo::UNDEFINED_LOOKUP); if (s->cache_info.action != CACHE_DO_WRITE) { @@ -3648,13 +3646,13 @@ HttpTransact::handle_response_from_parent(State *s) } if (s->current.retry_attempts.get() < (s->txn_conf->parent_connect_attempts - 1)) { - HTTP_INCREMENT_DYN_STAT(http_total_parent_retries_stat); + Metrics::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 - HTTP_INCREMENT_DYN_STAT(http_total_parent_switches_stat); + Metrics::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); @@ -3662,7 +3660,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()); - HTTP_INCREMENT_DYN_STAT(http_total_parent_retries_exhausted_stat); + Metrics::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 @@ -3676,7 +3674,7 @@ HttpTransact::handle_response_from_parent(State *s) } else { // Done trying parents... fail over to origin server if that is // appropriate - HTTP_INCREMENT_DYN_STAT(http_total_parent_retries_exhausted_stat); + Metrics::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); @@ -3897,7 +3895,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); - HTTP_INCREMENT_DYN_STAT(http_broken_server_connections_stat); + Metrics::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(); @@ -4358,7 +4356,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); - HTTP_INCREMENT_DYN_STAT(http_cache_updates_stat); + Metrics::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 @@ -4561,12 +4559,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); - HTTP_INCREMENT_DYN_STAT(http_cache_deletes_stat); + Metrics::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); - HTTP_INCREMENT_DYN_STAT(http_cache_writes_stat); + Metrics::increment(http_rsb.cache_writes); break; case CACHE_DO_SERVE_AND_UPDATE: // fall through @@ -4575,7 +4573,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); - HTTP_INCREMENT_DYN_STAT(http_cache_updates_stat); + Metrics::increment(http_rsb.cache_updates); break; default: break; @@ -5419,7 +5417,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. - HTTP_INCREMENT_DYN_STAT(http_missing_host_hdr_stat); + Metrics::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 @@ -5576,7 +5574,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; - HTTP_INCREMENT_DYN_STAT(http_tunnels_stat); + Metrics::increment(http_rsb.tunnels); return false; } @@ -5642,7 +5640,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; - HTTP_INCREMENT_DYN_STAT(http_tunnels_stat); + Metrics::increment(http_rsb.tunnels); } return false; @@ -5750,27 +5748,27 @@ HttpTransact::initialize_state_variables_from_request(State *s, HTTPHdr *obsolet if (!do_increment_stat) { ; } else if (s->method == HTTP_WKSIDX_GET) { - HTTP_INCREMENT_DYN_STAT(http_get_requests_stat); + Metrics::increment(http_rsb.get_requests); } else if (s->method == HTTP_WKSIDX_HEAD) { - HTTP_INCREMENT_DYN_STAT(http_head_requests_stat); + Metrics::increment(http_rsb.head_requests); } else if (s->method == HTTP_WKSIDX_POST) { - HTTP_INCREMENT_DYN_STAT(http_post_requests_stat); + Metrics::increment(http_rsb.post_requests); } else if (s->method == HTTP_WKSIDX_PUT) { - HTTP_INCREMENT_DYN_STAT(http_put_requests_stat); + Metrics::increment(http_rsb.put_requests); } else if (s->method == HTTP_WKSIDX_CONNECT) { - HTTP_INCREMENT_DYN_STAT(http_connect_requests_stat); + Metrics::increment(http_rsb.connect_requests); } else if (s->method == HTTP_WKSIDX_DELETE) { - HTTP_INCREMENT_DYN_STAT(http_delete_requests_stat); + Metrics::increment(http_rsb.delete_requests); } else if (s->method == HTTP_WKSIDX_PURGE) { - HTTP_INCREMENT_DYN_STAT(http_purge_requests_stat); + Metrics::increment(http_rsb.purge_requests); } else if (s->method == HTTP_WKSIDX_TRACE) { - HTTP_INCREMENT_DYN_STAT(http_trace_requests_stat); + Metrics::increment(http_rsb.trace_requests); } else if (s->method == HTTP_WKSIDX_PUSH) { - HTTP_INCREMENT_DYN_STAT(http_push_requests_stat); + Metrics::increment(http_rsb.push_requests); } else if (s->method == HTTP_WKSIDX_OPTIONS) { - HTTP_INCREMENT_DYN_STAT(http_options_requests_stat); + Metrics::increment(http_rsb.options_requests); } else { - HTTP_INCREMENT_DYN_STAT(http_extension_method_requests_stat); + Metrics::increment(http_rsb.extension_method_requests); SET_VIA_STRING(VIA_DETAIL_TUNNEL, VIA_DETAIL_TUNNEL_METHOD); s->squid_codes.log_code = SQUID_LOG_TCP_MISS; s->hdr_info.extension_method = true; @@ -6625,7 +6623,7 @@ HttpTransact::will_this_request_self_loop(State *s) break; } SET_VIA_STRING(VIA_ERROR_TYPE, VIA_ERROR_LOOP_DETECTED); - HTTP_INCREMENT_DYN_STAT(http_proxy_loop_detected_stat); + Metrics::increment(http_rsb.proxy_loop_detected); build_error_response(s, HTTP_STATUS_BAD_REQUEST, "Cycle Detected", "request#cycle_detected"); return true; } @@ -6659,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); - HTTP_INCREMENT_DYN_STAT(http_proxy_mh_loop_detected_stat); + Metrics::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 { @@ -7828,7 +7826,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"); - HTTP_INCREMENT_DYN_STAT(http_outgoing_requests_stat); + Metrics::increment(http_rsb.outgoing_requests); } // build a (status_code) response based upon the given info @@ -8306,74 +8304,6 @@ HttpTransact::milestone_update_api_time(State *s) s->state_machine->milestone_update_api_time(); } -void -HttpTransact::histogram_response_document_size(State *s, int64_t doc_size) -{ - if (doc_size >= 0 && doc_size <= 100) { - HTTP_INCREMENT_DYN_STAT(http_response_document_size_100_stat); - } else if (doc_size <= 1024) { - HTTP_INCREMENT_DYN_STAT(http_response_document_size_1K_stat); - } else if (doc_size <= 3072) { - HTTP_INCREMENT_DYN_STAT(http_response_document_size_3K_stat); - } else if (doc_size <= 5120) { - HTTP_INCREMENT_DYN_STAT(http_response_document_size_5K_stat); - } else if (doc_size <= 10240) { - HTTP_INCREMENT_DYN_STAT(http_response_document_size_10K_stat); - } else if (doc_size <= 1048576) { - HTTP_INCREMENT_DYN_STAT(http_response_document_size_1M_stat); - } else { - HTTP_INCREMENT_DYN_STAT(http_response_document_size_inf_stat); - } - return; -} - -void -HttpTransact::histogram_request_document_size(State *s, int64_t doc_size) -{ - if (doc_size >= 0 && doc_size <= 100) { - HTTP_INCREMENT_DYN_STAT(http_request_document_size_100_stat); - } else if (doc_size <= 1024) { - HTTP_INCREMENT_DYN_STAT(http_request_document_size_1K_stat); - } else if (doc_size <= 3072) { - HTTP_INCREMENT_DYN_STAT(http_request_document_size_3K_stat); - } else if (doc_size <= 5120) { - HTTP_INCREMENT_DYN_STAT(http_request_document_size_5K_stat); - } else if (doc_size <= 10240) { - HTTP_INCREMENT_DYN_STAT(http_request_document_size_10K_stat); - } else if (doc_size <= 1048576) { - HTTP_INCREMENT_DYN_STAT(http_request_document_size_1M_stat); - } else { - HTTP_INCREMENT_DYN_STAT(http_request_document_size_inf_stat); - } - return; -} - -void -HttpTransact::user_agent_connection_speed(State *s, ink_hrtime transfer_time, int64_t nbytes) -{ - float bytes_per_hrtime = - (transfer_time == 0) ? (nbytes) : (static_cast(nbytes) / static_cast(static_cast(transfer_time))); - int bytes_per_sec = static_cast(bytes_per_hrtime * HRTIME_SECOND); - - if (bytes_per_sec <= 100) { - HTTP_INCREMENT_DYN_STAT(http_user_agent_speed_bytes_per_sec_100_stat); - } else if (bytes_per_sec <= 1024) { - HTTP_INCREMENT_DYN_STAT(http_user_agent_speed_bytes_per_sec_1K_stat); - } else if (bytes_per_sec <= 10240) { - HTTP_INCREMENT_DYN_STAT(http_user_agent_speed_bytes_per_sec_10K_stat); - } else if (bytes_per_sec <= 102400) { - HTTP_INCREMENT_DYN_STAT(http_user_agent_speed_bytes_per_sec_100K_stat); - } else if (bytes_per_sec <= 1048576) { - HTTP_INCREMENT_DYN_STAT(http_user_agent_speed_bytes_per_sec_1M_stat); - } else if (bytes_per_sec <= 10485760) { - HTTP_INCREMENT_DYN_STAT(http_user_agent_speed_bytes_per_sec_10M_stat); - } else { - HTTP_INCREMENT_DYN_STAT(http_user_agent_speed_bytes_per_sec_100M_stat); - } - - return; -} - /* * added request_process_time stat for loadshedding foo */ @@ -8396,68 +8326,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: - HTTP_INCREMENT_DYN_STAT(http_cache_miss_cold_stat); + Metrics::increment(http_rsb.cache_miss_cold); client_transaction_result = CLIENT_TRANSACTION_RESULT_ERROR_CONNECT_FAIL; break; case SQUID_LOG_TCP_CF_HIT: - HTTP_INCREMENT_DYN_STAT(http_cache_hit_rww_stat); + Metrics::increment(http_rsb.cache_hit_rww); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_MEM_HIT: - HTTP_INCREMENT_DYN_STAT(http_cache_hit_mem_fresh_stat); + Metrics::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. - HTTP_INCREMENT_DYN_STAT(http_cache_hit_fresh_stat); + Metrics::increment(http_rsb.cache_hit_fresh); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_REFRESH_HIT: - HTTP_INCREMENT_DYN_STAT(http_cache_hit_reval_stat); + Metrics::increment(http_rsb.cache_hit_reval); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_REVALIDATED; break; case SQUID_LOG_TCP_IMS_HIT: - HTTP_INCREMENT_DYN_STAT(http_cache_hit_ims_stat); + Metrics::increment(http_rsb.cache_hit_ims); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; case SQUID_LOG_TCP_REF_FAIL_HIT: - HTTP_INCREMENT_DYN_STAT(http_cache_hit_stale_served_stat); + Metrics::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)) { - HTTP_INCREMENT_DYN_STAT(http_cache_miss_cold_stat); + Metrics::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? - HTTP_INCREMENT_DYN_STAT(http_cache_miss_uncacheable_stat); + Metrics::increment(http_rsb.cache_miss_uncacheable); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_UNCACHABLE; } break; case SQUID_LOG_TCP_REFRESH_MISS: - HTTP_INCREMENT_DYN_STAT(http_cache_miss_changed_stat); + Metrics::increment(http_rsb.cache_miss_changed); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_CHANGED; break; case SQUID_LOG_TCP_CLIENT_REFRESH: - HTTP_INCREMENT_DYN_STAT(http_cache_miss_client_no_cache_stat); + Metrics::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: - HTTP_INCREMENT_DYN_STAT(http_cache_miss_ims_stat); + Metrics::increment(http_rsb.cache_miss_ims); client_transaction_result = CLIENT_TRANSACTION_RESULT_MISS_COLD; break; case SQUID_LOG_TCP_SWAPFAIL: - HTTP_INCREMENT_DYN_STAT(http_cache_read_error_stat); + Metrics::increment(http_rsb.cache_read_error); client_transaction_result = CLIENT_TRANSACTION_RESULT_HIT_FRESH; break; @@ -8490,143 +8420,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: - HTTP_INCREMENT_DYN_STAT(http_response_status_100_count_stat); + Metrics::increment(http_rsb.response_status_100_count); break; case 101: - HTTP_INCREMENT_DYN_STAT(http_response_status_101_count_stat); + Metrics::increment(http_rsb.response_status_101_count); break; case 200: - HTTP_INCREMENT_DYN_STAT(http_response_status_200_count_stat); + Metrics::increment(http_rsb.response_status_200_count); break; case 201: - HTTP_INCREMENT_DYN_STAT(http_response_status_201_count_stat); + Metrics::increment(http_rsb.response_status_201_count); break; case 202: - HTTP_INCREMENT_DYN_STAT(http_response_status_202_count_stat); + Metrics::increment(http_rsb.response_status_202_count); break; case 203: - HTTP_INCREMENT_DYN_STAT(http_response_status_203_count_stat); + Metrics::increment(http_rsb.response_status_203_count); break; case 204: - HTTP_INCREMENT_DYN_STAT(http_response_status_204_count_stat); + Metrics::increment(http_rsb.response_status_204_count); break; case 205: - HTTP_INCREMENT_DYN_STAT(http_response_status_205_count_stat); + Metrics::increment(http_rsb.response_status_205_count); break; case 206: - HTTP_INCREMENT_DYN_STAT(http_response_status_206_count_stat); + Metrics::increment(http_rsb.response_status_206_count); break; case 300: - HTTP_INCREMENT_DYN_STAT(http_response_status_300_count_stat); + Metrics::increment(http_rsb.response_status_300_count); break; case 301: - HTTP_INCREMENT_DYN_STAT(http_response_status_301_count_stat); + Metrics::increment(http_rsb.response_status_301_count); break; case 302: - HTTP_INCREMENT_DYN_STAT(http_response_status_302_count_stat); + Metrics::increment(http_rsb.response_status_302_count); break; case 303: - HTTP_INCREMENT_DYN_STAT(http_response_status_303_count_stat); + Metrics::increment(http_rsb.response_status_303_count); break; case 304: - HTTP_INCREMENT_DYN_STAT(http_response_status_304_count_stat); + Metrics::increment(http_rsb.response_status_304_count); break; case 305: - HTTP_INCREMENT_DYN_STAT(http_response_status_305_count_stat); + Metrics::increment(http_rsb.response_status_305_count); break; case 307: - HTTP_INCREMENT_DYN_STAT(http_response_status_307_count_stat); + Metrics::increment(http_rsb.response_status_307_count); break; case 308: - HTTP_INCREMENT_DYN_STAT(http_response_status_308_count_stat); + Metrics::increment(http_rsb.response_status_308_count); break; case 400: - HTTP_INCREMENT_DYN_STAT(http_response_status_400_count_stat); + Metrics::increment(http_rsb.response_status_400_count); break; case 401: - HTTP_INCREMENT_DYN_STAT(http_response_status_401_count_stat); + Metrics::increment(http_rsb.response_status_401_count); break; case 402: - HTTP_INCREMENT_DYN_STAT(http_response_status_402_count_stat); + Metrics::increment(http_rsb.response_status_402_count); break; case 403: - HTTP_INCREMENT_DYN_STAT(http_response_status_403_count_stat); + Metrics::increment(http_rsb.response_status_403_count); break; case 404: - HTTP_INCREMENT_DYN_STAT(http_response_status_404_count_stat); + Metrics::increment(http_rsb.response_status_404_count); break; case 405: - HTTP_INCREMENT_DYN_STAT(http_response_status_405_count_stat); + Metrics::increment(http_rsb.response_status_405_count); break; case 406: - HTTP_INCREMENT_DYN_STAT(http_response_status_406_count_stat); + Metrics::increment(http_rsb.response_status_406_count); break; case 407: - HTTP_INCREMENT_DYN_STAT(http_response_status_407_count_stat); + Metrics::increment(http_rsb.response_status_407_count); break; case 408: - HTTP_INCREMENT_DYN_STAT(http_response_status_408_count_stat); + Metrics::increment(http_rsb.response_status_408_count); break; case 409: - HTTP_INCREMENT_DYN_STAT(http_response_status_409_count_stat); + Metrics::increment(http_rsb.response_status_409_count); break; case 410: - HTTP_INCREMENT_DYN_STAT(http_response_status_410_count_stat); + Metrics::increment(http_rsb.response_status_410_count); break; case 411: - HTTP_INCREMENT_DYN_STAT(http_response_status_411_count_stat); + Metrics::increment(http_rsb.response_status_411_count); break; case 412: - HTTP_INCREMENT_DYN_STAT(http_response_status_412_count_stat); + Metrics::increment(http_rsb.response_status_412_count); break; case 413: - HTTP_INCREMENT_DYN_STAT(http_response_status_413_count_stat); + Metrics::increment(http_rsb.response_status_413_count); break; case 414: - HTTP_INCREMENT_DYN_STAT(http_response_status_414_count_stat); + Metrics::increment(http_rsb.response_status_414_count); break; case 415: - HTTP_INCREMENT_DYN_STAT(http_response_status_415_count_stat); + Metrics::increment(http_rsb.response_status_415_count); break; case 416: - HTTP_INCREMENT_DYN_STAT(http_response_status_416_count_stat); + Metrics::increment(http_rsb.response_status_416_count); break; case 500: - HTTP_INCREMENT_DYN_STAT(http_response_status_500_count_stat); + Metrics::increment(http_rsb.response_status_500_count); break; case 501: - HTTP_INCREMENT_DYN_STAT(http_response_status_501_count_stat); + Metrics::increment(http_rsb.response_status_501_count); break; case 502: - HTTP_INCREMENT_DYN_STAT(http_response_status_502_count_stat); + Metrics::increment(http_rsb.response_status_502_count); break; case 503: - HTTP_INCREMENT_DYN_STAT(http_response_status_503_count_stat); + Metrics::increment(http_rsb.response_status_503_count); break; case 504: - HTTP_INCREMENT_DYN_STAT(http_response_status_504_count_stat); + Metrics::increment(http_rsb.response_status_504_count); break; case 505: - HTTP_INCREMENT_DYN_STAT(http_response_status_505_count_stat); + Metrics::increment(http_rsb.response_status_505_count); break; default: break; } switch (client_response_status / 100) { case 1: - HTTP_INCREMENT_DYN_STAT(http_response_status_1xx_count_stat); + Metrics::increment(http_rsb.response_status_1xx_count); break; case 2: - HTTP_INCREMENT_DYN_STAT(http_response_status_2xx_count_stat); + Metrics::increment(http_rsb.response_status_2xx_count); break; case 3: - HTTP_INCREMENT_DYN_STAT(http_response_status_3xx_count_stat); + Metrics::increment(http_rsb.response_status_3xx_count); break; case 4: - HTTP_INCREMENT_DYN_STAT(http_response_status_4xx_count_stat); + Metrics::increment(http_rsb.response_status_4xx_count); break; case 5: - HTTP_INCREMENT_DYN_STAT(http_response_status_5xx_count_stat); + Metrics::increment(http_rsb.response_status_5xx_count); break; default: break; @@ -8634,77 +8564,63 @@ HttpTransact::client_result_stat(State *s, ink_hrtime total_time, ink_hrtime req } // Increment the completed connection count - HTTP_INCREMENT_DYN_STAT(http_completed_requests_stat); + Metrics::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: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_hit_fresh_stat, total_msec); - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_hit_fresh_process_stat, process_msec); + 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); break; case CLIENT_TRANSACTION_RESULT_HIT_REVALIDATED: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_hit_reval_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_hit_reval); + Metrics::increment(http_rsb.ua_msecs_hit_reval, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_COLD: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_miss_cold_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_miss_cold); + Metrics::increment(http_rsb.ua_msecs_miss_cold, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_CHANGED: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_miss_changed_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_miss_changed); + Metrics::increment(http_rsb.ua_msecs_miss_changed, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_CLIENT_NO_CACHE: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_miss_client_no_cache_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_miss_client_no_cache); + Metrics::increment(http_rsb.ua_msecs_miss_client_no_cache, total_msec); break; case CLIENT_TRANSACTION_RESULT_MISS_UNCACHABLE: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_miss_uncacheable_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_miss_uncacheable); + Metrics::increment(http_rsb.ua_msecs_miss_uncacheable, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_ABORT: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_aborts_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_errors_aborts); + Metrics::increment(http_rsb.ua_msecs_errors_aborts, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_POSSIBLE_ABORT: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_possible_aborts_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_errors_possible_aborts); + Metrics::increment(http_rsb.ua_msecs_errors_possible_aborts, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_CONNECT_FAIL: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_connect_failed_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_errors_connect_failed); + Metrics::increment(http_rsb.ua_msecs_errors_connect_failed, total_msec); break; case CLIENT_TRANSACTION_RESULT_ERROR_OTHER: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_other_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_errors_other); + Metrics::increment(http_rsb.ua_msecs_errors_other, total_msec); break; default: - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_other_unclassified_stat, total_msec); + Metrics::increment(http_rsb.ua_counts_other_unclassified); + Metrics::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; } } -void -HttpTransact::origin_server_connection_speed(State *s, ink_hrtime transfer_time, int64_t nbytes) -{ - float bytes_per_hrtime = - (transfer_time == 0) ? (nbytes) : (static_cast(nbytes) / static_cast(static_cast(transfer_time))); - int bytes_per_sec = static_cast(bytes_per_hrtime * HRTIME_SECOND); - - if (bytes_per_sec <= 100) { - HTTP_INCREMENT_DYN_STAT(http_origin_server_speed_bytes_per_sec_100_stat); - } else if (bytes_per_sec <= 1024) { - HTTP_INCREMENT_DYN_STAT(http_origin_server_speed_bytes_per_sec_1K_stat); - } else if (bytes_per_sec <= 10240) { - HTTP_INCREMENT_DYN_STAT(http_origin_server_speed_bytes_per_sec_10K_stat); - } else if (bytes_per_sec <= 102400) { - HTTP_INCREMENT_DYN_STAT(http_origin_server_speed_bytes_per_sec_100K_stat); - } else if (bytes_per_sec <= 1048576) { - HTTP_INCREMENT_DYN_STAT(http_origin_server_speed_bytes_per_sec_1M_stat); - } else if (bytes_per_sec <= 10485760) { - HTTP_INCREMENT_DYN_STAT(http_origin_server_speed_bytes_per_sec_10M_stat); - } else { - HTTP_INCREMENT_DYN_STAT(http_origin_server_speed_bytes_per_sec_100M_stat); - } - - return; -} - void HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hrtime user_agent_write_time, ink_hrtime origin_server_read_time, int user_agent_request_header_size, @@ -8727,7 +8643,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); - HTTP_SUM_DYN_STAT(http_background_fill_bytes_completed_stat, bg_size); + Metrics::increment(http_rsb.background_fill_bytes_completed, bg_size); break; } case BACKGROUND_FILL_ABORTED: { @@ -8736,7 +8652,7 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr if (bg_size < 0) { bg_size = 0; } - HTTP_SUM_DYN_STAT(http_background_fill_bytes_aborted_stat, bg_size); + Metrics::increment(http_rsb.background_fill_bytes_aborted, bg_size); break; } case BACKGROUND_FILL_NONE: @@ -8752,144 +8668,133 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr case SQUID_LOG_TCP_MEM_HIT: case SQUID_LOG_TCP_CF_HIT: // It's possible to have two stat's instead of one, if needed. - HTTP_INCREMENT_DYN_STAT(http_tcp_hit_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_hit_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_hit_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_TCP_MISS: - HTTP_INCREMENT_DYN_STAT(http_tcp_miss_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_miss_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_miss_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_TCP_EXPIRED_MISS: - HTTP_INCREMENT_DYN_STAT(http_tcp_expired_miss_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_expired_miss_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_expired_miss_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_TCP_REFRESH_HIT: - HTTP_INCREMENT_DYN_STAT(http_tcp_refresh_hit_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_refresh_hit_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_refresh_hit_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_TCP_REFRESH_MISS: - HTTP_INCREMENT_DYN_STAT(http_tcp_refresh_miss_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_refresh_miss_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_refresh_miss_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_TCP_CLIENT_REFRESH: - HTTP_INCREMENT_DYN_STAT(http_tcp_client_refresh_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_client_refresh_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_client_refresh_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_TCP_IMS_HIT: - HTTP_INCREMENT_DYN_STAT(http_tcp_ims_hit_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_ims_hit_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_ims_hit_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_TCP_IMS_MISS: - HTTP_INCREMENT_DYN_STAT(http_tcp_ims_miss_count_stat); - HTTP_SUM_DYN_STAT(http_tcp_ims_miss_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_tcp_ims_miss_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_ERR_CLIENT_ABORT: - HTTP_INCREMENT_DYN_STAT(http_err_client_abort_count_stat); - HTTP_SUM_DYN_STAT(http_err_client_abort_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_err_client_abort_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_ERR_CLIENT_READ_ERROR: - HTTP_INCREMENT_DYN_STAT(http_err_client_read_error_count_stat); - HTTP_SUM_DYN_STAT(http_err_client_read_error_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_err_client_read_error_origin_server_bytes_stat, origin_server_bytes); + 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); break; case SQUID_LOG_ERR_CONNECT_FAIL: - HTTP_INCREMENT_DYN_STAT(http_err_connect_fail_count_stat); - HTTP_SUM_DYN_STAT(http_err_connect_fail_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_err_connect_fail_origin_server_bytes_stat, origin_server_bytes); + 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); break; default: - HTTP_INCREMENT_DYN_STAT(http_misc_count_stat); - HTTP_SUM_DYN_STAT(http_misc_user_agent_bytes_stat, user_agent_bytes); - HTTP_SUM_DYN_STAT(http_misc_origin_server_bytes_stat, origin_server_bytes); + 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); break; } // times - HTTP_SUM_DYN_STAT(http_total_transactions_time_stat, total_time); + Metrics::increment(http_rsb.total_transactions_time, total_time); // sizes - HTTP_SUM_DYN_STAT(http_user_agent_request_header_total_size_stat, user_agent_request_header_size); - HTTP_SUM_DYN_STAT(http_user_agent_response_header_total_size_stat, user_agent_response_header_size); - HTTP_SUM_DYN_STAT(http_user_agent_request_document_total_size_stat, user_agent_request_body_size); - HTTP_SUM_DYN_STAT(http_user_agent_response_document_total_size_stat, user_agent_response_body_size); + 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); // proxy stats if (s->current.request_to == ResolveInfo::PARENT_PROXY) { - HTTP_SUM_DYN_STAT(http_parent_proxy_request_total_bytes_stat, - origin_server_request_header_size + origin_server_request_body_size); - HTTP_SUM_DYN_STAT(http_parent_proxy_response_total_bytes_stat, - origin_server_response_header_size + origin_server_response_body_size); - HTTP_SUM_DYN_STAT(http_parent_proxy_transaction_time_stat, total_time); + 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); } // request header zero means the document was cached. // do not add to stats. if (origin_server_request_header_size > 0) { - HTTP_SUM_DYN_STAT(http_origin_server_request_header_total_size_stat, origin_server_request_header_size); - HTTP_SUM_DYN_STAT(http_origin_server_response_header_total_size_stat, origin_server_response_header_size); - HTTP_SUM_DYN_STAT(http_origin_server_request_document_total_size_stat, origin_server_request_body_size); - HTTP_SUM_DYN_STAT(http_origin_server_response_document_total_size_stat, origin_server_response_body_size); + 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); } if (s->method == HTTP_WKSIDX_PUSH) { - HTTP_SUM_DYN_STAT(http_pushed_response_header_total_size_stat, pushed_response_header_size); - HTTP_SUM_DYN_STAT(http_pushed_document_total_size_stat, pushed_response_body_size); - } - - histogram_request_document_size(s, user_agent_request_body_size); - histogram_response_document_size(s, user_agent_response_body_size); - - if (user_agent_write_time >= 0) { - user_agent_connection_speed(s, user_agent_write_time, user_agent_response_size); - } - - if (origin_server_request_header_size > 0 && origin_server_read_time > 0) { - origin_server_connection_speed(s, origin_server_read_time, origin_server_response_size); + 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); } // update milestones stats - HTTP_SUM_DYN_STAT(http_ua_begin_time_stat, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN, 0)); - HTTP_SUM_DYN_STAT(http_ua_first_read_time_stat, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_FIRST_READ, 0)); - HTTP_SUM_DYN_STAT(http_ua_read_header_done_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_READ_HEADER_DONE, 0)); - HTTP_SUM_DYN_STAT(http_ua_begin_write_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_BEGIN_WRITE, 0)); - HTTP_SUM_DYN_STAT(http_ua_close_time_stat, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_UA_CLOSE, 0)); - HTTP_SUM_DYN_STAT(http_server_first_connect_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_CONNECT, 0)); - HTTP_SUM_DYN_STAT(http_server_connect_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT, 0)); - HTTP_SUM_DYN_STAT(http_server_connect_end_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CONNECT_END, 0)); - HTTP_SUM_DYN_STAT(http_server_begin_write_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_BEGIN_WRITE, 0)); - HTTP_SUM_DYN_STAT(http_server_first_read_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_FIRST_READ, 0)); - HTTP_SUM_DYN_STAT(http_server_read_header_done_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_READ_HEADER_DONE, 0)); - HTTP_SUM_DYN_STAT(http_server_close_time_stat, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SERVER_CLOSE, 0)); - HTTP_SUM_DYN_STAT(http_cache_open_read_begin_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_BEGIN, 0)); - HTTP_SUM_DYN_STAT(http_cache_open_read_end_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_READ_END, 0)); - HTTP_SUM_DYN_STAT(http_cache_open_write_begin_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_BEGIN, 0)); - HTTP_SUM_DYN_STAT(http_cache_open_write_end_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_CACHE_OPEN_WRITE_END, 0)); - HTTP_SUM_DYN_STAT(http_dns_lookup_begin_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_BEGIN, 0)); - HTTP_SUM_DYN_STAT(http_dns_lookup_end_time_stat, - milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_DNS_LOOKUP_END, 0)); - HTTP_SUM_DYN_STAT(http_sm_start_time_stat, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_START, 0)); - HTTP_SUM_DYN_STAT(http_sm_finish_time_stat, milestones.difference_msec(TS_MILESTONE_SM_START, TS_MILESTONE_SM_FINISH, 0)); + 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)); } void diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h index ff32c2d0273..f4779da4458 100644 --- a/proxy/http/HttpTransact.h +++ b/proxy/http/HttpTransact.h @@ -1108,10 +1108,6 @@ class HttpTransact int64_t pushed_response_body_size, const TransactionMilestones &milestones); static void milestone_start_api_time(State *s); static void milestone_update_api_time(State *s); - static void histogram_request_document_size(State *s, int64_t size); - static void histogram_response_document_size(State *s, int64_t size); - static void user_agent_connection_speed(State *s, ink_hrtime transfer_time, int64_t nbytes); - static void origin_server_connection_speed(State *s, ink_hrtime transfer_time, int64_t nbytes); static void client_result_stat(State *s, ink_hrtime total_time, ink_hrtime request_process_time); static void delete_warning_value(HTTPHdr *to_warn, HTTPWarningCode warning_code); static bool is_connection_collapse_checks_success(State *s); // YTS Team, yamsat diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc index f113f2b755d..671bbbefa00 100644 --- a/proxy/http/HttpTunnel.cc +++ b/proxy/http/HttpTunnel.cc @@ -1480,7 +1480,7 @@ HttpTunnel::chain_abort_all(HttpTunnelProducer *p) } p->read_vio = nullptr; p->vc->do_io_close(EHTTP_ERROR); - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_tunnel_abort); + Metrics::increment(http_rsb.origin_shutdown_tunnel_abort); update_stats_after_abort(p->vc_type); } } @@ -1597,7 +1597,7 @@ HttpTunnel::chain_abort_cache_write(HttpTunnelProducer *p) c->write_vio = nullptr; c->vc->do_io_close(EHTTP_ERROR); c->alive = false; - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::decrement(http_rsb.current_cache_connections); } else if (c->self_producer) { chain_abort_cache_write(c->self_producer); } @@ -1711,7 +1711,7 @@ HttpTunnel::update_stats_after_abort(HttpTunnelType_t t) switch (t) { case HT_CACHE_READ: case HT_CACHE_WRITE: - HTTP_DECREMENT_DYN_STAT(http_current_cache_connections_stat); + Metrics::decrement(http_rsb.current_cache_connections); break; default: // Handled here: @@ -1736,7 +1736,7 @@ HttpTunnel::mark_tls_tunnel_active() } _tls_tunnel_active = true; - HTTP_INCREMENT_DYN_STAT(tunnel_current_active_connections_stat); + Metrics::increment(http_rsb.tunnel_current_active_connections); _schedule_tls_tunnel_activity_check_event(); } @@ -1749,7 +1749,7 @@ HttpTunnel::mark_tls_tunnel_inactive() } _tls_tunnel_active = false; - HTTP_DECREMENT_DYN_STAT(tunnel_current_active_connections_stat); + Metrics::decrement(http_rsb.tunnel_current_active_connections); if (_tls_tunnel_activity_check_event) { _tls_tunnel_activity_check_event->cancel(); diff --git a/proxy/http/HttpVCTable.cc b/proxy/http/HttpVCTable.cc index 09efb4b3b9e..0667009317a 100644 --- a/proxy/http/HttpVCTable.cc +++ b/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) { - HTTP_INCREMENT_DYN_STAT(http_origin_shutdown_cleanup_entry); + Metrics::increment(http_rsb.origin_shutdown_cleanup_entry); } e->vc->do_io_close(); e->vc = nullptr; diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc index 454d040b618..9ee035d2377 100644 --- a/proxy/http2/HTTP2.cc +++ b/proxy/http2/HTTP2.cc @@ -48,40 +48,7 @@ static VersionConverter hvc; } // namespace // Statistics -RecRawStatBlock *http2_rsb; -static const char *const HTTP2_STAT_CURRENT_CLIENT_CONNECTION_NAME = "proxy.process.http2.current_client_connections"; -static const char *const HTTP2_STAT_CURRENT_SERVER_CONNECTION_NAME = "proxy.process.http2.current_server_connections"; -static const char *const HTTP2_STAT_CURRENT_ACTIVE_CLIENT_CONNECTION_NAME = "proxy.process.http2.current_active_client_connections"; -static const char *const HTTP2_STAT_CURRENT_ACTIVE_SERVER_CONNECTION_NAME = "proxy.process.http2.current_active_server_connections"; -static const char *const HTTP2_STAT_CURRENT_CLIENT_STREAM_NAME = "proxy.process.http2.current_client_streams"; -static const char *const HTTP2_STAT_CURRENT_SERVER_STREAM_NAME = "proxy.process.http2.current_server_streams"; -static const char *const HTTP2_STAT_TOTAL_CLIENT_STREAM_NAME = "proxy.process.http2.total_client_streams"; -static const char *const HTTP2_STAT_TOTAL_SERVER_STREAM_NAME = "proxy.process.http2.total_server_streams"; -static const char *const HTTP2_STAT_TOTAL_TRANSACTIONS_TIME_NAME = "proxy.process.http2.total_transactions_time"; -static const char *const HTTP2_STAT_TOTAL_CLIENT_CONNECTION_NAME = "proxy.process.http2.total_client_connections"; -static const char *const HTTP2_STAT_TOTAL_SERVER_CONNECTION_NAME = "proxy.process.http2.total_server_connections"; -static const char *const HTTP2_STAT_CONNECTION_ERRORS_NAME = "proxy.process.http2.connection_errors"; -static const char *const HTTP2_STAT_STREAM_ERRORS_NAME = "proxy.process.http2.stream_errors"; -static const char *const HTTP2_STAT_SESSION_DIE_DEFAULT_NAME = "proxy.process.http2.session_die_default"; -static const char *const HTTP2_STAT_SESSION_DIE_OTHER_NAME = "proxy.process.http2.session_die_other"; -static const char *const HTTP2_STAT_SESSION_DIE_ACTIVE_NAME = "proxy.process.http2.session_die_active"; -static const char *const HTTP2_STAT_SESSION_DIE_INACTIVE_NAME = "proxy.process.http2.session_die_inactive"; -static const char *const HTTP2_STAT_SESSION_DIE_EOS_NAME = "proxy.process.http2.session_die_eos"; -static const char *const HTTP2_STAT_SESSION_DIE_ERROR_NAME = "proxy.process.http2.session_die_error"; -static const char *const HTTP2_STAT_SESSION_DIE_HIGH_ERROR_RATE_NAME = "proxy.process.http2.session_die_high_error_rate"; -static const char *const HTTP2_STAT_MAX_SETTINGS_PER_FRAME_EXCEEDED_NAME = "proxy.process.http2.max_settings_per_frame_exceeded"; -static const char *const HTTP2_STAT_MAX_SETTINGS_PER_MINUTE_EXCEEDED_NAME = "proxy.process.http2.max_settings_per_minute_exceeded"; -static const char *const HTTP2_STAT_MAX_SETTINGS_FRAMES_PER_MINUTE_EXCEEDED_NAME = - "proxy.process.http2.max_settings_frames_per_minute_exceeded"; -static const char *const HTTP2_STAT_MAX_PING_FRAMES_PER_MINUTE_EXCEEDED_NAME = - "proxy.process.http2.max_ping_frames_per_minute_exceeded"; -static const char *const HTTP2_STAT_MAX_PRIORITY_FRAMES_PER_MINUTE_EXCEEDED_NAME = - "proxy.process.http2.max_priority_frames_per_minute_exceeded"; -static const char *const HTTP2_STAT_INSUFFICIENT_AVG_WINDOW_UPDATE_NAME = "proxy.process.http2.insufficient_avg_window_update"; -static const char *const HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_IN_NAME = - "proxy.process.http2.max_concurrent_streams_exceeded_in"; -static const char *const HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_OUT_NAME = - "proxy.process.http2.max_concurrent_streams_exceeded_out"; +Http2StatsBlock http2_rsb; union byte_pointer { byte_pointer(void *p) : ptr(p) {} @@ -600,69 +567,38 @@ Http2::init() } while (0); // Setup statistics - http2_rsb = RecAllocateRawStatBlock(static_cast(HTTP2_N_STATS)); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_CLIENT_CONNECTION_NAME, RECD_INT, RECP_NON_PERSISTENT, - static_cast(HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT), RecRawStatSyncSum); - HTTP2_CLEAR_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_SERVER_CONNECTION_NAME, RECD_INT, RECP_NON_PERSISTENT, - static_cast(HTTP2_STAT_CURRENT_SERVER_SESSION_COUNT), RecRawStatSyncSum); - HTTP2_CLEAR_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_SESSION_COUNT); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_ACTIVE_CLIENT_CONNECTION_NAME, RECD_INT, RECP_NON_PERSISTENT, - static_cast(HTTP2_STAT_CURRENT_ACTIVE_CLIENT_CONNECTION_COUNT), RecRawStatSyncSum); - HTTP2_CLEAR_DYN_STAT(HTTP2_STAT_CURRENT_ACTIVE_CLIENT_CONNECTION_COUNT); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_ACTIVE_SERVER_CONNECTION_NAME, RECD_INT, RECP_NON_PERSISTENT, - static_cast(HTTP2_STAT_CURRENT_ACTIVE_SERVER_CONNECTION_COUNT), RecRawStatSyncSum); - HTTP2_CLEAR_DYN_STAT(HTTP2_STAT_CURRENT_ACTIVE_SERVER_CONNECTION_COUNT); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_CLIENT_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, - static_cast(HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT), RecRawStatSyncSum); - HTTP2_CLEAR_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CURRENT_SERVER_STREAM_NAME, RECD_INT, RECP_NON_PERSISTENT, - static_cast(HTTP2_STAT_CURRENT_SERVER_STREAM_COUNT), RecRawStatSyncSum); - HTTP2_CLEAR_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_STREAM_COUNT); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_CLIENT_STREAM_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_TOTAL_CLIENT_STREAM_COUNT), RecRawStatSyncCount); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_SERVER_STREAM_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_TOTAL_SERVER_STREAM_COUNT), RecRawStatSyncCount); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_TRANSACTIONS_TIME_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_TOTAL_TRANSACTIONS_TIME), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_CLIENT_CONNECTION_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_TOTAL_CLIENT_CONNECTION_COUNT), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_TOTAL_SERVER_CONNECTION_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_TOTAL_SERVER_CONNECTION_COUNT), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_CONNECTION_ERRORS_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_CONNECTION_ERRORS_COUNT), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_STREAM_ERRORS_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_STREAM_ERRORS_COUNT), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_SESSION_DIE_DEFAULT_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_SESSION_DIE_DEFAULT), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_SESSION_DIE_OTHER_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_SESSION_DIE_OTHER), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_SESSION_DIE_EOS_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_SESSION_DIE_EOS), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_SESSION_DIE_ACTIVE_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_SESSION_DIE_ACTIVE), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_SESSION_DIE_INACTIVE_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_SESSION_DIE_INACTIVE), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_SESSION_DIE_ERROR_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_SESSION_DIE_ERROR), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_SESSION_DIE_HIGH_ERROR_RATE_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_SESSION_DIE_HIGH_ERROR_RATE), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_MAX_SETTINGS_PER_FRAME_EXCEEDED_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_MAX_SETTINGS_PER_FRAME_EXCEEDED), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_MAX_SETTINGS_PER_MINUTE_EXCEEDED_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_MAX_SETTINGS_PER_MINUTE_EXCEEDED), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_MAX_SETTINGS_FRAMES_PER_MINUTE_EXCEEDED_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_MAX_SETTINGS_FRAMES_PER_MINUTE_EXCEEDED), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_MAX_PING_FRAMES_PER_MINUTE_EXCEEDED_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_MAX_PING_FRAMES_PER_MINUTE_EXCEEDED), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_MAX_PRIORITY_FRAMES_PER_MINUTE_EXCEEDED_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_MAX_PRIORITY_FRAMES_PER_MINUTE_EXCEEDED), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_INSUFFICIENT_AVG_WINDOW_UPDATE_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_INSUFFICIENT_AVG_WINDOW_UPDATE), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_IN_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_IN), RecRawStatSyncSum); - RecRegisterRawStat(http2_rsb, RECT_PROCESS, HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_OUT_NAME, RECD_INT, RECP_PERSISTENT, - static_cast(HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_OUT), RecRawStatSyncSum); + 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.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"); + http2_rsb.max_priority_frames_per_minute_exceeded = + intm.newMetricPtr("proxy.process.http2.max_priority_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"); http2_init(); } diff --git a/proxy/http2/HTTP2.h b/proxy/http2/HTTP2.h index 65b5413ef84..2c65a6b323a 100644 --- a/proxy/http2/HTTP2.h +++ b/proxy/http2/HTTP2.h @@ -29,6 +29,10 @@ #include "MIME.h" #include "records/I_RecDefs.h" +#include "api/Metrics.h" + +using ts::Metrics; + class HTTPHdr; // [RFC 9113] 5.1.1 Stream identifiers. @@ -72,43 +76,38 @@ const uint32_t HTTP2_PRIORITY_DEFAULT_STREAM_DEPENDENCY = 0; const uint8_t HTTP2_PRIORITY_DEFAULT_WEIGHT = 15; // Statistics -enum { - HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT, // Current # of inbound HTTP2 connections - HTTP2_STAT_CURRENT_SERVER_SESSION_COUNT, // Current # of outbound HTTP2 connections - HTTP2_STAT_CURRENT_ACTIVE_CLIENT_CONNECTION_COUNT, // Current # of active inbound HTTP2 connections - HTTP2_STAT_CURRENT_ACTIVE_SERVER_CONNECTION_COUNT, // Current # of active outbound HTTP2 connections - HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT, // Current # of active inbound HTTP2 streams - HTTP2_STAT_CURRENT_SERVER_STREAM_COUNT, // Current # of active outboundHTTP2 streams - HTTP2_STAT_TOTAL_CLIENT_STREAM_COUNT, - HTTP2_STAT_TOTAL_SERVER_STREAM_COUNT, - HTTP2_STAT_TOTAL_TRANSACTIONS_TIME, // Total stream time and streams - HTTP2_STAT_TOTAL_CLIENT_CONNECTION_COUNT, // Total inbound connections running http2 - HTTP2_STAT_TOTAL_SERVER_CONNECTION_COUNT, // Total outbound connections running http2 - HTTP2_STAT_STREAM_ERRORS_COUNT, - HTTP2_STAT_CONNECTION_ERRORS_COUNT, - HTTP2_STAT_SESSION_DIE_DEFAULT, - HTTP2_STAT_SESSION_DIE_OTHER, - HTTP2_STAT_SESSION_DIE_ACTIVE, - HTTP2_STAT_SESSION_DIE_INACTIVE, - HTTP2_STAT_SESSION_DIE_EOS, - HTTP2_STAT_SESSION_DIE_ERROR, - HTTP2_STAT_SESSION_DIE_HIGH_ERROR_RATE, - HTTP2_STAT_MAX_SETTINGS_PER_FRAME_EXCEEDED, - HTTP2_STAT_MAX_SETTINGS_PER_MINUTE_EXCEEDED, - HTTP2_STAT_MAX_SETTINGS_FRAMES_PER_MINUTE_EXCEEDED, - HTTP2_STAT_MAX_PING_FRAMES_PER_MINUTE_EXCEEDED, - HTTP2_STAT_MAX_PRIORITY_FRAMES_PER_MINUTE_EXCEEDED, - HTTP2_STAT_INSUFFICIENT_AVG_WINDOW_UPDATE, - HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_IN, - HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_OUT, - - HTTP2_N_STATS // Terminal counter, NOT A STAT INDEX. +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 *insufficient_avg_window_update; + Metrics::IntType *max_concurrent_streams_exceeded_in; + Metrics::IntType *max_concurrent_streams_exceeded_out; }; -#define HTTP2_INCREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStat(http2_rsb, _t, (int)_s, 1); -#define HTTP2_DECREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStat(http2_rsb, _t, (int)_s, -1); -#define HTTP2_SUM_THREAD_DYN_STAT(_s, _t, _v) RecIncrRawStat(http2_rsb, _t, (int)_s, _v); -extern RecRawStatBlock *http2_rsb; // Container for statistics. +extern Http2StatsBlock http2_rsb; // [RFC 7540] 6.9.1. The Flow Control Window static const Http2WindowSize HTTP2_MAX_WINDOW_SIZE = 0x7FFFFFFF; diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc index 8684f7257d3..4e945deba01 100644 --- a/proxy/http2/Http2ClientSession.cc +++ b/proxy/http2/Http2ClientSession.cc @@ -60,7 +60,7 @@ Http2ClientSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT, mutex_thread); + Metrics::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()); - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_SESSION_COUNT, new_vc->mutex->thread_holding); - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_CLIENT_CONNECTION_COUNT, new_vc->mutex->thread_holding); + Metrics::increment(http2_rsb.current_client_session_count); + Metrics::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() { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_ACTIVE_CLIENT_CONNECTION_COUNT, this_ethread()); + Metrics::increment(http2_rsb.current_active_client_connection_count); } void Http2ClientSession::decrement_current_active_connections_stat() { - HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_ACTIVE_CLIENT_CONNECTION_COUNT, this_ethread()); + Metrics::decrement(http2_rsb.current_active_client_connection_count); } sockaddr const * diff --git a/proxy/http2/Http2CommonSession.cc b/proxy/http2/Http2CommonSession.cc index 613d6a1de42..768e90e17c6 100644 --- a/proxy/http2/Http2CommonSession.cc +++ b/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: - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_HIGH_ERROR_RATE, this_ethread()); + Metrics::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. - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_OTHER, this_ethread()); + Metrics::increment(http2_rsb.session_die_other); break; } } else { switch (dying_event) { case VC_EVENT_NONE: - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_DEFAULT, this_ethread()); + Metrics::increment(http2_rsb.session_die_default); break; case VC_EVENT_ACTIVE_TIMEOUT: - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_ACTIVE, this_ethread()); + Metrics::increment(http2_rsb.session_die_active); break; case VC_EVENT_INACTIVITY_TIMEOUT: - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_INACTIVE, this_ethread()); + Metrics::increment(http2_rsb.session_die_inactive); break; case VC_EVENT_ERROR: - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_ERROR, this_ethread()); + Metrics::increment(http2_rsb.session_die_error); break; case VC_EVENT_EOS: - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_EOS, this_ethread()); + Metrics::increment(http2_rsb.session_die_eos); break; default: - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_SESSION_DIE_OTHER, this_ethread()); + Metrics::increment(http2_rsb.session_die_other); break; } } diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc index fbc53d9f382..39ab088b700 100644 --- a/proxy/http2/Http2ConnectionState.cc +++ b/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 (Http2::max_priority_frames_per_minute != 0 && this->get_received_priority_frame_count() > Http2::max_priority_frames_per_minute) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_MAX_PRIORITY_FRAMES_PER_MINUTE_EXCEEDED, this_ethread()); + Metrics::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, @@ -664,7 +664,7 @@ Http2ConnectionState::rcv_settings_frame(const Http2Frame &frame) this->increment_received_settings_frame_count(); // Close this connection if its SETTINGS frame count exceeds a limit if (this->get_received_settings_frame_count() > Http2::max_settings_frames_per_minute) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_MAX_SETTINGS_FRAMES_PER_MINUTE_EXCEEDED, this_ethread()); + Metrics::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, @@ -704,7 +704,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) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_MAX_SETTINGS_PER_FRAME_EXCEEDED, this_ethread()); + Metrics::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"); @@ -745,7 +745,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) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_MAX_SETTINGS_PER_MINUTE_EXCEEDED, this_ethread()); + Metrics::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, @@ -799,7 +799,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 (this->get_received_ping_frame_count() > Http2::max_ping_frames_per_minute) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_MAX_PING_FRAMES_PER_MINUTE_EXCEEDED, this_ethread()); + Metrics::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, @@ -1616,10 +1616,8 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error) // stream limit to be exceeded MUST treat this as a stream error. int check_max_concurrent_limit = 0; int check_count = 0; - int max_streams_stat = 0; if (is_client_streamid) { - check_count = peer_streams_count_in; - max_streams_stat = HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_IN; + check_count = peer_streams_count_in; // If this is an outbound client stream, must check against the peer's max_concurrent if (session->is_outbound()) { check_max_concurrent_limit = peer_settings.get(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); @@ -1627,8 +1625,7 @@ Http2ConnectionState::create_stream(Http2StreamId new_id, Http2Error &error) check_max_concurrent_limit = acknowledged_local_settings.get(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); } } else { // Not a client stream (i.e. a push) - check_count = peer_streams_count_out; - max_streams_stat = HTTP2_STAT_MAX_CONCURRENT_STREAMS_EXCEEDED_OUT; + check_count = peer_streams_count_out; // If this is an outbound non-client stream, must check against the local max_concurrent if (session->is_outbound()) { check_max_concurrent_limit = acknowledged_local_settings.get(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); @@ -1638,7 +1635,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) { - HTTP2_INCREMENT_THREAD_DYN_STAT(max_streams_stat, this_ethread()); + Metrics::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; @@ -2394,7 +2392,7 @@ Http2ConnectionState::send_rst_stream_frame(Http2StreamId id, Http2ErrorCode ec) Http2StreamDebug(session, id, "Send RST_STREAM frame"); if (ec != Http2ErrorCode::HTTP2_ERROR_NO_ERROR) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_STREAM_ERRORS_COUNT, this_ethread()); + Metrics::increment(http2_rsb.stream_errors_count); ++stream_error_count; } @@ -2502,7 +2500,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) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CONNECTION_ERRORS_COUNT, this_ethread()); + Metrics::increment(http2_rsb.connection_errors_count); } this->tx_error_code = {ProxyErrorClass::SSN, static_cast(ec)}; @@ -2590,8 +2588,7 @@ Http2ConnectionState::_adjust_concurrent_stream() return max_concurrent_streams; } - int64_t current_client_streams = 0; - RecGetRawStatSum(http2_rsb, HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT, ¤t_client_streams); + int64_t current_client_streams = Metrics::read(http2_rsb.current_client_stream_count); Http2ConDebug(session, "current client streams: %" PRId64, current_client_streams); @@ -2660,7 +2657,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) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_INSUFFICIENT_AVG_WINDOW_UPDATE, this_ethread()); + Metrics::increment(http2_rsb.insufficient_avg_window_update); return Http2ErrorCode::HTTP2_ERROR_ENHANCE_YOUR_CALM; } return Http2ErrorCode::HTTP2_ERROR_NO_ERROR; diff --git a/proxy/http2/Http2ServerSession.cc b/proxy/http2/Http2ServerSession.cc index 81d9aad92cc..38e8cf3d3cb 100644 --- a/proxy/http2/Http2ServerSession.cc +++ b/proxy/http2/Http2ServerSession.cc @@ -61,7 +61,7 @@ Http2ServerSession::free() { auto mutex_thread = this->mutex->thread_holding; if (Http2CommonSession::common_free(this)) { - HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_SESSION_COUNT, mutex_thread); + Metrics::decrement(http2_rsb.current_server_session_count); THREAD_FREE(this, http2ServerSessionAllocator, mutex_thread); } } @@ -95,8 +95,9 @@ void Http2ServerSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOBufferReader *reader) { ink_assert(new_vc->mutex->thread_holding == this_ethread()); - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_SESSION_COUNT, new_vc->mutex->thread_holding); - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_SERVER_CONNECTION_COUNT, new_vc->mutex->thread_holding); + + Metrics::increment(http2_rsb.current_server_session_count); + Metrics::increment(http2_rsb.total_server_connection_count); this->_milestones.mark(Http2SsnMilestone::OPEN); // Unique client session identifier. @@ -245,18 +246,6 @@ Http2ServerSession::main_event_handler(int event, void *edata) return retval; } -void -Http2ServerSession::increment_current_active_connections_stat() -{ - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_ACTIVE_SERVER_CONNECTION_COUNT, this_ethread()); -} - -void -Http2ServerSession::decrement_current_active_connections_stat() -{ - HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_ACTIVE_SERVER_CONNECTION_COUNT, this_ethread()); -} - sockaddr const * Http2ServerSession::get_remote_addr() const { diff --git a/proxy/http2/Http2ServerSession.h b/proxy/http2/Http2ServerSession.h index 93d8f9fbf2f..30f3a074b7e 100644 --- a/proxy/http2/Http2ServerSession.h +++ b/proxy/http2/Http2ServerSession.h @@ -65,12 +65,22 @@ class Http2ServerSession : public PoolableSession, public Http2CommonSession int populate_protocol(std::string_view *result, int size) const override; const char *protocol_contains(std::string_view prefix) const override; HTTPVersion get_version(HTTPHdr &hdr) const override; - void increment_current_active_connections_stat() override; - void decrement_current_active_connections_stat() override; IOBufferReader *get_remote_reader() override; ProxySession *get_proxy_session() override; + void + increment_current_active_connections_stat() override + { + Metrics::increment(http2_rsb.current_active_server_connection_count); + } + + void + decrement_current_active_connections_stat() override + { + Metrics::decrement(http2_rsb.current_active_server_connection_count); + } + // noncopyable Http2ServerSession(Http2ServerSession &) = delete; Http2ServerSession &operator=(const Http2ServerSession &) = delete; diff --git a/proxy/http2/Http2SessionAccept.cc b/proxy/http2/Http2SessionAccept.cc index f0226fdee86..4455975da21 100644 --- a/proxy/http2/Http2SessionAccept.cc +++ b/proxy/http2/Http2SessionAccept.cc @@ -81,7 +81,8 @@ Http2SessionAccept::mainEvent(int event, void *data) // XXX We should hoist the error handling so that all the protocols generate the statistics // without code duplication. if (((long)data) == -ECONNABORTED) { - HTTP_SUM_DYN_STAT(http_ua_msecs_counts_errors_pre_accept_hangups_stat, 0); + 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 } ink_abort("HTTP/2 accept received fatal error: errno = %d", -(static_cast((intptr_t)data))); diff --git a/proxy/http2/Http2Stream.cc b/proxy/http2/Http2Stream.cc index 1d35d82aacc..24ac4ab1ece 100644 --- a/proxy/http2/Http2Stream.cc +++ b/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); - HTTP2_SUM_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_TRANSACTIONS_TIME, this->_thread, total_time); + Metrics::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()) { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_STREAM_COUNT, _thread); - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_SERVER_STREAM_COUNT, _thread); + Metrics::increment(http2_rsb.current_server_stream_count); + Metrics::increment(http2_rsb.total_server_stream_count); } else { - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT, _thread); - HTTP2_INCREMENT_THREAD_DYN_STAT(HTTP2_STAT_TOTAL_CLIENT_STREAM_COUNT, _thread); + Metrics::increment(http2_rsb.current_client_stream_count); + Metrics::increment(http2_rsb.total_client_stream_count); } } @@ -1042,9 +1042,9 @@ void Http2Stream::decrement_transactions_stat() { if (this->is_outbound_connection()) { - HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_SERVER_STREAM_COUNT, _thread); + Metrics::decrement(http2_rsb.current_server_stream_count); } else { - HTTP2_DECREMENT_THREAD_DYN_STAT(HTTP2_STAT_CURRENT_CLIENT_STREAM_COUNT, _thread); + Metrics::decrement(http2_rsb.current_client_stream_count); } } diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc index 0e2ee40e867..4957b391449 100644 --- a/proxy/logging/Log.cc +++ b/proxy/logging/Log.cc @@ -78,7 +78,7 @@ uint32_t Log::periodic_tasks_interval = PERIODIC_TASKS_INTERVAL_FALLBACK; // Hash table for LogField symbols std::unordered_map Log::field_symbol_hash; -RecRawStatBlock *log_rsb; +LogsStatsBlock log_rsb; /*------------------------------------------------------------------------- Log::change_configuration @@ -1042,7 +1042,6 @@ Log::init(int flags) if (config_flags & LOGCAT) { logging_mode = LOG_MODE_NONE; } else { - log_rsb = RecAllocateRawStatBlock(static_cast(log_stat_count)); LogConfig::register_stat_callbacks(); config->read_configuration_variables(); @@ -1075,11 +1074,6 @@ Log::init(int flags) // if (!(config_flags & NO_REMOTE_MANAGEMENT)) { REC_RegisterConfigUpdateFunc("proxy.config.log.logging_enabled", &Log::handle_logging_mode_change, nullptr); - - // Clear any stat values that need to be reset on startup - // - RecSetRawStatSum(log_rsb, log_stat_log_files_open_stat, 0); - RecSetRawStatCount(log_rsb, log_stat_log_files_open_stat, 0); } init_fields(); @@ -1169,7 +1163,6 @@ Log::access(LogAccess *lad) int ret; static long sample = 1; long this_sample; - ProxyMutex *mutex = this_ethread()->mutex.get(); // See if we're sampling and it is not time for another sample // @@ -1177,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 ..."); - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_access_skip_stat, 1); + Metrics::increment(log_rsb.event_log_access_skip); ret = Log::SKIP; goto done; } else { @@ -1188,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 ..."); - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_access_skip_stat, 1); + Metrics::increment(log_rsb.event_log_access_skip); ret = Log::SKIP; goto done; } @@ -1224,8 +1217,7 @@ Log::error(const char *format, ...) int Log::va_error(const char *format, va_list ap) { - int ret_val = Log::SKIP; - ProxyMutex *mutex = this_ethread()->mutex.get(); + int ret_val = Log::SKIP; if (error_log) { ink_assert(format != nullptr); @@ -1233,19 +1225,19 @@ Log::va_error(const char *format, va_list ap) switch (ret_val) { case Log::LOG_OK: - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_error_ok_stat, 1); + Metrics::increment(log_rsb.event_log_error_ok); break; case Log::SKIP: - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_error_skip_stat, 1); + Metrics::increment(log_rsb.event_log_error_skip); break; case Log::AGGR: - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_error_aggr_stat, 1); + Metrics::increment(log_rsb.event_log_error_aggr); break; case Log::FULL: - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_error_full_stat, 1); + Metrics::increment(log_rsb.event_log_error_full); break; case Log::FAIL: - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_error_fail_stat, 1); + Metrics::increment(log_rsb.event_log_error_fail); break; default: ink_release_assert(!"Unexpected result"); @@ -1254,7 +1246,7 @@ Log::va_error(const char *format, va_list ap) return ret_val; } - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_error_skip_stat, 1); + Metrics::increment(log_rsb.event_log_error_skip); return ret_val; } @@ -1314,7 +1306,6 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */) ink_hrtime now, last_time = 0; int len, total_bytes; SLL link, invert_link; - ProxyMutex *mutex = this_thread()->mutex.get(); Log::flush_notify->lock(); @@ -1358,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); - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_bytes_lost_before_written_to_disk_stat, total_bytes); + Metrics::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes); delete fdata; continue; } @@ -1374,8 +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)); - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_bytes_lost_before_written_to_disk_stat, - total_bytes - bytes_written); + Metrics::increment(log_rsb.bytes_lost_before_written_to_disk, total_bytes - bytes_written); break; } @@ -1385,15 +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)); - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_bytes_lost_before_written_to_disk_stat, - total_bytes - bytes_written); + Metrics::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; } - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_bytes_written_to_disk_stat, bytes_written); + Metrics::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/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc index f0b18431472..36ed7187ea0 100644 --- a/proxy/logging/LogAccess.cc +++ b/proxy/logging/LogAccess.cc @@ -214,9 +214,21 @@ LogAccess::marshal_record(char *record, char *buf) RecDataT stype = RECD_NULL; bool found = false; + // 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) { - out_buf = "INVALID_RECORD"; - num_chars = ::strlen(out_buf) + 1; + ts::Metrics &intm = ts::Metrics::getInstance(); + ts::Metrics::IdType metric = intm[record]; + + if (metric != ts::Metrics::NOT_FOUND) { + int64_t val = intm[metric]; + + out_buf = int64_to_str(ascii_buf, max_chars, val, &num_chars); + ink_assert(out_buf); + } else { + out_buf = "INVALID_RECORD"; + num_chars = ::strlen(out_buf) + 1; + } } else { if (LOG_INTEGER == stype || LOG_COUNTER == stype) { // we assume MgmtInt and MgmtIntCounter are int64_t for the diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc index 8ecdf563443..ec9e9e93627 100644 --- a/proxy/logging/LogConfig.cc +++ b/proxy/logging/LogConfig.cc @@ -507,62 +507,32 @@ LogConfig::register_stat_callbacks() // // events // - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_error_ok", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_error_ok_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_error_skip", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_error_skip_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_error_aggr", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_error_aggr_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_error_full", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_error_full_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_error_fail", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_error_fail_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_access_ok", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_access_ok_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_access_skip", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_access_skip_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_access_aggr", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_access_aggr_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_access_full", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_access_full_stat, RecRawStatSyncCount); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.event_log_access_fail", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_event_log_access_fail_stat, RecRawStatSyncCount); - // - // number vs bytes of logs - // - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.num_sent_to_network", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_num_sent_to_network_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.num_lost_before_sent_to_network", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_num_lost_before_sent_to_network_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.num_received_from_network", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_num_received_from_network_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.num_flush_to_disk", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_num_flush_to_disk_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.num_lost_before_flush_to_disk", RECD_COUNTER, RECP_PERSISTENT, - (int)log_stat_num_lost_before_flush_to_disk_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_lost_before_preproc", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_lost_before_preproc_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_sent_to_network", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_sent_to_network_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_lost_before_sent_to_network", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_lost_before_sent_to_network_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_received_from_network", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_received_from_network_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_flush_to_disk", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_flush_to_disk_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_lost_before_flush_to_disk", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_lost_before_flush_to_disk_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_written_to_disk", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_written_to_disk_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.bytes_lost_before_written_to_disk", RECD_INT, RECP_PERSISTENT, - (int)log_stat_bytes_lost_before_written_to_disk_stat, RecRawStatSyncSum); - // - // I/O - // - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.log_files_open", RECD_COUNTER, RECP_NON_PERSISTENT, - (int)log_stat_log_files_open_stat, RecRawStatSyncSum); - RecRegisterRawStat(log_rsb, RECT_PROCESS, "proxy.process.log.log_files_space_used", RECD_INT, RECP_NON_PERSISTENT, - (int)log_stat_log_files_space_used_stat, RecRawStatSyncSum); + 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"); } /*------------------------------------------------------------------------- @@ -688,8 +658,7 @@ LogConfig::update_space_used() // m_space_used = total_space_used; m_partition_space_left = partition_space_left; - RecSetRawStatSum(log_rsb, log_stat_log_files_space_used_stat, m_space_used); - RecSetRawStatCount(log_rsb, log_stat_log_files_space_used_stat, 1); + Metrics::write(log_rsb.log_files_space_used, m_space_used); Debug("logspace", "%" PRId64 " bytes being used for logs", m_space_used); Debug("logspace", "%" PRId64 " bytes left on partition", m_partition_space_left); diff --git a/proxy/logging/LogConfig.h b/proxy/logging/LogConfig.h index b0ddbd344a2..1bc2fbb8c25 100644 --- a/proxy/logging/LogConfig.h +++ b/proxy/logging/LogConfig.h @@ -32,49 +32,39 @@ #include "LogObject.h" #include "RolledLogDeleter.h" #include "swoc/MemSpan.h" - -/* Instead of enumerating the stats in DynamicStats.h, each module needs - to enumerate its stats separately and register them with librecords - */ -enum { - // Logging Events - log_stat_event_log_error_ok_stat, - log_stat_event_log_error_skip_stat, - log_stat_event_log_error_aggr_stat, - log_stat_event_log_error_full_stat, - log_stat_event_log_error_fail_stat, - - log_stat_event_log_access_ok_stat, - log_stat_event_log_access_skip_stat, - log_stat_event_log_access_aggr_stat, - log_stat_event_log_access_full_stat, - log_stat_event_log_access_fail_stat, - - // Logging Data - log_stat_num_sent_to_network_stat, - log_stat_num_lost_before_sent_to_network_stat, - log_stat_num_received_from_network_stat, - log_stat_num_flush_to_disk_stat, - log_stat_num_lost_before_flush_to_disk_stat, - - log_stat_bytes_lost_before_preproc_stat, - log_stat_bytes_sent_to_network_stat, - log_stat_bytes_lost_before_sent_to_network_stat, - log_stat_bytes_received_from_network_stat, - - log_stat_bytes_flush_to_disk_stat, - log_stat_bytes_lost_before_flush_to_disk_stat, - log_stat_bytes_written_to_disk_stat, - log_stat_bytes_lost_before_written_to_disk_stat, - - // Logging I/O - log_stat_log_files_open_stat, - log_stat_log_files_space_used_stat, - - log_stat_count +#include "api/Metrics.h" + +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; }; -extern RecRawStatBlock *log_rsb; +extern LogsStatsBlock log_rsb; struct dirent; diff --git a/proxy/logging/LogFile.cc b/proxy/logging/LogFile.cc index 6b708a2a300..6e28dd6ea51 100644 --- a/proxy/logging/LogFile.cc +++ b/proxy/logging/LogFile.cc @@ -223,7 +223,7 @@ LogFile::open_file() } } - RecIncrRawStat(log_rsb, this_thread()->mutex->thread_holding, log_stat_log_files_open_stat, 1); + Metrics::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); - RecIncrRawStat(log_rsb, this_thread()->mutex->thread_holding, log_stat_log_files_open_stat, -1); + Metrics::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()); - RecIncrRawStat(log_rsb, this_thread()->mutex->thread_holding, log_stat_log_files_open_stat, -1); + Metrics::decrement(log_rsb.log_files_open); } } else { Warning("LogFile %s is open but was not closed", m_name); @@ -454,11 +454,8 @@ LogFile::preproc_and_try_delete(LogBuffer *lb) // LogFlushData *flush_data = new LogFlushData(this, lb); - ProxyMutex *mutex = this_thread()->mutex.get(); - - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_num_flush_to_disk_stat, lb->header()->entry_count); - - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_bytes_flush_to_disk_stat, lb->header()->byte_count); + Metrics::increment(log_rsb.num_flush_to_disk, lb->header()->entry_count); + Metrics::increment(log_rsb.bytes_flush_to_disk, lb->header()->byte_count); ink_atomiclist_push(Log::flush_data_list, flush_data); @@ -563,7 +560,6 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader *buffer_header, const char *alt_ m_name, this); ink_assert(buffer_header != nullptr); - ProxyMutex *mutex = this_thread()->mutex.get(); LogBufferIterator iter(buffer_header); LogEntryHeader *entry_header; int fmt_entry_count = 0; @@ -617,9 +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); - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_num_lost_before_flush_to_disk_stat, fmt_entry_count); - - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_bytes_lost_before_flush_to_disk_stat, fmt_buf_bytes); + 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); } // if writing to a pipe, fill the buffer with a single // record to avoid as much as possible overflowing the @@ -638,9 +633,8 @@ LogFile::write_ascii_logbuffer3(LogBufferHeader *buffer_header, const char *alt_ // LogFlushData *flush_data = new LogFlushData(this, ascii_buffer, fmt_buf_bytes); - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_num_flush_to_disk_stat, fmt_entry_count); - - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_bytes_flush_to_disk_stat, 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); ink_atomiclist_push(Log::flush_data_list, flush_data); diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc index d88d02d50b7..70a8dbbc3a2 100644 --- a/proxy/logging/LogObject.cc +++ b/proxy/logging/LogObject.cc @@ -66,8 +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."); - RecIncrRawStat(log_rsb, this_thread()->mutex->thread_holding, log_stat_bytes_lost_before_preproc_stat, - b->header()->byte_count); + Metrics::increment(log_rsb.bytes_lost_before_preproc, b->header()->byte_count); delete b; } else { new_q.push(b); @@ -1338,8 +1337,7 @@ LogObjectManager::find_by_format_name(const char *name) const int LogObjectManager::log(LogAccess *lad) { - int ret = Log::SKIP; - ProxyMutex *mutex = this_thread()->mutex.get(); + int ret = Log::SKIP; for (unsigned i = 0; i < this->_objects.size(); i++) { ret |= _objects[i]->log(lad); @@ -1351,15 +1349,15 @@ LogObjectManager::log(LogAccess *lad) // The if-statement should keep step with the priority order. // if (unlikely(ret & Log::FAIL)) { - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_access_fail_stat, 1); + Metrics::increment(log_rsb.event_log_access_fail); } else if (unlikely(ret & Log::FULL)) { - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_access_full_stat, 1); + Metrics::increment(log_rsb.event_log_access_full); } else if (likely(ret & Log::LOG_OK)) { - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_access_ok_stat, 1); + Metrics::increment(log_rsb.event_log_access_ok); } else if (unlikely(ret & Log::AGGR)) { - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_access_aggr_stat, 1); + Metrics::increment(log_rsb.event_log_access_aggr); } else if (likely(ret & Log::SKIP)) { - RecIncrRawStat(log_rsb, mutex->thread_holding, log_stat_event_log_access_skip_stat, 1); + Metrics::increment(log_rsb.event_log_access_skip); } else { ink_release_assert(!"Unexpected result"); } diff --git a/src/api/InkAPI.cc b/src/api/InkAPI.cc index a8782ebe6b6..59c4ae95046 100644 --- a/src/api/InkAPI.cc +++ b/src/api/InkAPI.cc @@ -6561,29 +6561,20 @@ tsapi::c::TSHttpTxnLookingUpTypeGet(TSHttpTxn txnp) int tsapi::c::TSHttpCurrentClientConnectionsGet() { - int64_t S; - - HTTP_READ_DYN_SUM(http_current_client_connections_stat, S); - return static_cast(S); + return Metrics::read(http_rsb.current_client_connections); } int tsapi::c::TSHttpCurrentActiveClientConnectionsGet() { - int64_t S; - - HTTP_READ_DYN_SUM(http_current_active_client_connections_stat, S); - return static_cast(S); + return Metrics::read(http_rsb.current_active_client_connections); } int tsapi::c::TSHttpCurrentIdleClientConnectionsGet() { - int64_t total = 0; - int64_t active = 0; - - HTTP_READ_DYN_SUM(http_current_client_connections_stat, total); - HTTP_READ_DYN_SUM(http_current_active_client_connections_stat, active); + int64_t total = Metrics::read(http_rsb.current_client_connections); + int64_t active = Metrics::read(http_rsb.current_active_client_connections); if (total >= active) { return static_cast(total - active); @@ -6595,19 +6586,13 @@ tsapi::c::TSHttpCurrentIdleClientConnectionsGet() int tsapi::c::TSHttpCurrentCacheConnectionsGet() { - int64_t S; - - HTTP_READ_DYN_SUM(http_current_cache_connections_stat, S); - return static_cast(S); + return Metrics::read(http_rsb.current_cache_connections); } int tsapi::c::TSHttpCurrentServerConnectionsGet() { - int64_t S; - - HTTP_READ_GLOBAL_DYN_SUM(http_current_server_connections_stat, S); - return static_cast(S); + return Metrics::read(http_rsb.current_server_connections); } /* HTTP alternate selection */ @@ -7007,7 +6992,7 @@ tsapi::c::TSVConnCacheHttpInfoSet(TSVConn connp, TSCacheHttpInfo infop) sdk_assert(sdk_sanity_check_iocore_structure(connp) == TS_SUCCESS); CacheVC *vc = (CacheVC *)connp; - if (vc->base_stat == cache_scan_active_stat) { + if (static_cast(vc->op_type) == CacheOpType::Scan) { vc->set_http_info((CacheHTTPInfo *)infop); } } @@ -7423,14 +7408,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); + global_api_metrics[id].fetch_add(amount, ts::Metrics::MEMORY_ORDER); } void tsapi::c::TSStatIntDecrement(int id, TSMgmtInt amount) { sdk_assert(sdk_sanity_check_stat_id(id) == TS_SUCCESS); - global_api_metrics[id].fetch_sub(amount); + global_api_metrics[id].fetch_sub(amount, ts::Metrics::MEMORY_ORDER); } tsapi::c::TSMgmtInt diff --git a/src/api/Metrics.cc b/src/api/Metrics.cc index 1d38e04ea2f..c9e5c2eb55d 100644 --- a/src/api/Metrics.cc +++ b/src/api/Metrics.cc @@ -86,7 +86,7 @@ Metrics::lookup(const std::string_view name) const return NOT_FOUND; } -Metrics::AtomicType * +Metrics::IntType * Metrics::lookup(IdType id, std::string_view *name) const { auto [blob_ix, offset] = _splitID(id); diff --git a/src/records/RecCore.cc b/src/records/RecCore.cc index d79a37e61e7..a18fce2ea27 100644 --- a/src/records/RecCore.cc +++ b/src/records/RecCore.cc @@ -36,13 +36,13 @@ #include "tscpp/util/ts_errata.h" #include "api/Metrics.h" +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 // and used (read) from several binaries / modules. -int max_records_entries = REC_MAX_RECORDS; - +int max_records_entries = REC_MAX_RECORDS; static bool g_initialized = false; - -RecRecord *g_records = nullptr; +RecRecord *g_records = nullptr; std::unordered_map g_records_ht; ink_rwlock g_records_rwlock; int g_num_records = 0; diff --git a/src/records/RecRawStats.cc b/src/records/RecRawStats.cc index deaf8398250..ad16e4caf0f 100644 --- a/src/records/RecRawStats.cc +++ b/src/records/RecRawStats.cc @@ -24,6 +24,7 @@ Record statistics support #include "records/P_RecCore.h" #include "records/P_RecProcess.h" #include +#include //------------------------------------------------------------------------- // RecAllocateRawStatBlock @@ -340,15 +341,38 @@ RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatB return err; } +//------------------------------------------------------------------------- +// Register a new stats sync feature. ToDo: This is piggybacking on the +// old metrics for now, this should likely move to the Metrics interface +// later, and let it create a sync thread (or use TASK threads if these +// callbacks are deemed cheap.) +//------------------------------------------------------------------------- + +static std::list _newCbs; + +void +RecRegNewSyncStatSync(RecCallbackFunction callback) +{ + _newCbs.push_back(callback); +} + //------------------------------------------------------------------------- // RecExecRawStatSyncCbs //------------------------------------------------------------------------- + int RecExecRawStatSyncCbs() { RecRecord *r; int i, num_records; + // Call the new sync callbacks, needed for the new Metrics. ToDo: This should move + // once the old sync thread and events are completely removed. + for (const auto &callback : _newCbs) { + callback(); + } + + // Now sync all the legacy metrics num_records = g_num_records; for (i = 0; i < num_records; i++) { r = &(g_records[i]); diff --git a/src/traffic_server/traffic_server.cc b/src/traffic_server/traffic_server.cc index d80af430d62..7e634870ad4 100644 --- a/src/traffic_server/traffic_server.cc +++ b/src/traffic_server/traffic_server.cc @@ -1393,34 +1393,26 @@ struct ShowStats : public Continuation { if (!(cycle++ % 24)) { printf("r:rr w:ww r:rbs w:wbs open polls\n"); } - int64_t sval, cval; - - NET_READ_DYN_SUM(net_calls_to_readfromnet_stat, sval); - int64_t d_rb = sval - last_rb; + int64_t d_rb = Metrics::read(net_rsb.calls_to_readfromnet) - last_rb; last_rb += d_rb; - NET_READ_DYN_SUM(net_calls_to_writetonet_stat, sval); - int64_t d_wb = sval - last_wb; + int64_t d_wb = Metrics::read(net_rsb.calls_to_writetonet) - last_wb; last_wb += d_wb; - NET_READ_DYN_STAT(net_read_bytes_stat, sval, cval); - int64_t d_nrb = sval - last_nrb; + int64_t d_nrb = Metrics::read(net_rsb.read_bytes) - last_nrb; last_nrb += d_nrb; - int64_t d_nr = cval - last_nr; + int64_t d_nr = Metrics::read(net_rsb.read_bytes_count) - last_nr; last_nr += d_nr; - NET_READ_DYN_STAT(net_write_bytes_stat, sval, cval); - int64_t d_nwb = sval - last_nwb; + int64_t d_nwb = Metrics::read(net_rsb.write_bytes) - last_nwb; last_nwb += d_nwb; - int64_t d_nw = cval - last_nw; + int64_t d_nw = Metrics::read(net_rsb.write_bytes_count) - last_nw; last_nw += d_nw; - NET_READ_GLOBAL_DYN_SUM(net_connections_currently_open_stat, sval); - int64_t d_o = sval; + int64_t d_o = Metrics::read(net_rsb.connections_currently_open); + int64_t d_p = Metrics::read(net_rsb.handler_run) - last_p; - NET_READ_DYN_STAT(net_handler_run_stat, sval, cval); - int64_t d_p = cval - last_p; - last_p += d_p; + last_p += d_p; printf("%" PRId64 ":%" PRId64 ":%" PRId64 ":%" PRId64 " %" PRId64 ":%" PRId64 " %" PRId64 " %" PRId64 "\n", d_rb, d_wb, d_nrb, d_nr, d_nwb, d_nw, d_o, d_p); #ifdef ENABLE_TIME_TRACE diff --git a/src/traffic_top/stats.h b/src/traffic_top/stats.h index 037142b60c1..0cb12e411f0 100644 --- a/src/traffic_top/stats.h +++ b/src/traffic_top/stats.h @@ -261,14 +261,6 @@ class Stats lookup_table.insert(make_pair("505", LookupItem("505", "proxy.process.http.505_responses", 5))); lookup_table.insert(make_pair("5xx", LookupItem("5xx", "proxy.process.http.5xx_responses", 5))); - lookup_table.insert(make_pair("s_100", LookupItem("100 B", "proxy.process.http.response_document_size_100", 5))); - lookup_table.insert(make_pair("s_1k", LookupItem("1 KB", "proxy.process.http.response_document_size_1K", 5))); - lookup_table.insert(make_pair("s_3k", LookupItem("3 KB", "proxy.process.http.response_document_size_3K", 5))); - lookup_table.insert(make_pair("s_5k", LookupItem("5 KB", "proxy.process.http.response_document_size_5K", 5))); - lookup_table.insert(make_pair("s_10k", LookupItem("10 KB", "proxy.process.http.response_document_size_10K", 5))); - lookup_table.insert(make_pair("s_1m", LookupItem("1 MB", "proxy.process.http.response_document_size_1M", 5))); - lookup_table.insert(make_pair("s_>1m", LookupItem("> 1 MB", "proxy.process.http.response_document_size_inf", 5))); - // sum together lookup_table.insert(make_pair("ram_hit_miss", LookupItem("Ram Hit+Miss", "ram_hit", "ram_miss", 6))); lookup_table.insert(make_pair("client_net", LookupItem("Net (bits)", "client_head", "client_body", 7))); diff --git a/src/traffic_top/traffic_top.cc b/src/traffic_top/traffic_top.cc index 4bddbc393cb..cbf2c338cf3 100644 --- a/src/traffic_top/traffic_top.cc +++ b/src/traffic_top/traffic_top.cc @@ -341,13 +341,6 @@ main_stats_page(Stats &stats) response2.push_back("304"); response2.push_back("404"); response2.push_back("502"); - response2.push_back("s_100"); - response2.push_back("s_1k"); - response2.push_back("s_3k"); - response2.push_back("s_5k"); - response2.push_back("s_10k"); - response2.push_back("s_1m"); - response2.push_back("s_>1m"); makeTable(62, 1, response2, stats); list client1;