|
31 | 31 | #include "../iocore/eventsystem/P_VConnection.h" |
32 | 32 | #include "iocore/utils/OneWayTunnel.h" |
33 | 33 | #include "proxy/http/HttpSessionAccept.h" |
| 34 | +#include "tsutil/Metrics.h" |
34 | 35 |
|
35 | 36 | static DbgCtl dbg_ctl_SocksProxy("SocksProxy"); |
36 | 37 |
|
37 | | -enum { |
38 | | - socksproxy_http_connections_stat, |
39 | | - socksproxy_tunneled_connections_stat, |
40 | | - |
41 | | - socksproxy_stat_count |
42 | | -}; |
43 | | -static RecRawStatBlock *socksproxy_stat_block; |
44 | | - |
45 | | -#define SOCKSPROXY_INC_STAT(x) RecIncrRawStat(socksproxy_stat_block, mutex->thread_holding, x) |
| 38 | +namespace |
| 39 | +{ |
| 40 | +struct { |
| 41 | + ts::Metrics::Counter::AtomicType *http_connections; |
| 42 | + ts::Metrics::Counter::AtomicType *tunneled_connections; |
| 43 | +} stats; |
| 44 | +} // namespace |
46 | 45 |
|
47 | 46 | struct SocksProxy; |
48 | 47 | using SocksProxyHandler = int (SocksProxy::*)(int, void *); |
@@ -508,7 +507,7 @@ SocksProxy::parse_socks_client_request(unsigned char *p) |
508 | 507 | sendResp(true); |
509 | 508 | state = HTTP_REQ; |
510 | 509 | } else { |
511 | | - SOCKSPROXY_INC_STAT(socksproxy_tunneled_connections_stat); |
| 510 | + ts::Metrics::Counter::increment(stats.tunneled_connections); |
512 | 511 | Dbg(dbg_ctl_SocksProxy, "Tunnelling the connection for port %d", port); |
513 | 512 |
|
514 | 513 | if (clientVC->socks_addr.type != SOCKS_ATYPE_IPV4) { |
@@ -555,7 +554,7 @@ SocksProxy::state_handing_over_http_request(int event, [[maybe_unused]] void *da |
555 | 554 | case VC_EVENT_WRITE_COMPLETE: { |
556 | 555 | HttpSessionAccept::Options ha_opt; |
557 | 556 |
|
558 | | - SOCKSPROXY_INC_STAT(socksproxy_http_connections_stat); |
| 557 | + ts::Metrics::Counter::increment(stats.http_connections); |
559 | 558 | Dbg(dbg_ctl_SocksProxy, "Handing over the HTTP request"); |
560 | 559 |
|
561 | 560 | ha_opt.transport_type = clientVC->attributes; |
@@ -707,15 +706,8 @@ start_SocksProxy(int port) |
707 | 706 | opt.local_port = port; |
708 | 707 | netProcessor.main_accept(new SocksAccepter(), NO_FD, opt); |
709 | 708 |
|
710 | | - socksproxy_stat_block = RecAllocateRawStatBlock(socksproxy_stat_count); |
711 | | - |
712 | | - if (socksproxy_stat_block) { |
713 | | - RecRegisterRawStat(socksproxy_stat_block, RECT_PROCESS, "proxy.process.socks.proxy.http_connections", RECD_INT, RECP_PERSISTENT, |
714 | | - socksproxy_http_connections_stat, RecRawStatSyncCount); |
715 | | - |
716 | | - RecRegisterRawStat(socksproxy_stat_block, RECT_PROCESS, "proxy.process.socks.proxy.tunneled_connections", RECD_INT, |
717 | | - RECP_PERSISTENT, socksproxy_tunneled_connections_stat, RecRawStatSyncCount); |
718 | | - } |
| 709 | + stats.http_connections = ts::Metrics::Counter::createPtr("proxy.process.socks.proxy.http_connections"); |
| 710 | + stats.tunneled_connections = ts::Metrics::Counter::createPtr("proxy.process.socks.proxy.tunneled_connections"); |
719 | 711 | } |
720 | 712 |
|
721 | 713 | int |
|
0 commit comments