summaryrefslogtreecommitdiff
path: root/platform/src
diff options
context:
space:
mode:
authorluwenpeng <[email protected]>2023-05-06 19:04:06 +0800
committerluwenpeng <[email protected]>2023-05-08 15:32:55 +0800
commit7c3b77fb2f8de60a93a6ae2ef1c36d1e6646dbce (patch)
tree9bd2d45cc514252ecbd4114400e311056025c78f /platform/src
parent5dcc85c1ee0316f70fe0b0c600b8e91e7887f10a (diff)
TSG-14890 TFE输出Intercept Policy Hits Metricsv4.8.8-20230508
Diffstat (limited to 'platform/src')
-rw-r--r--platform/src/tcp_stream.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp
index 46c0b33..559aae3 100644
--- a/platform/src/tcp_stream.cpp
+++ b/platform/src/tcp_stream.cpp
@@ -26,6 +26,7 @@
#include <tfe_future.h>
#include <tfe_plugin.h>
#include <tfe_proxy.h>
+#include <tfe_fieldstat.h>
#include <platform.h>
#include <ssl_stream.h>
@@ -491,6 +492,17 @@ static void __stream_bev_passthrough_readcb(struct bufferevent * bev, void * arg
{
TFE_PROXY_STAT_INCREASE(STAT_STREAM_BYPASS, 1);
_stream->is_first_call_rxcb = 1;
+ tfe_set_intercept_metric(&_stream->head, 1, 0, 0, 0, 0);
+ }
+
+ int inbuff_len = evbuffer_get_length(__input_buffer);
+ if (bev == _stream->conn_downstream->bev)
+ {
+ tfe_set_intercept_metric(&_stream->head, 0, 1, inbuff_len, 0, 0);
+ }
+ else
+ {
+ tfe_set_intercept_metric(&_stream->head, 0, 0, 0, 1, inbuff_len);
}
struct evbuffer * __output_buffer = bufferevent_get_output(peer_conn->bev);
@@ -649,6 +661,13 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
assert(0);
}
+ if (_stream->is_first_call_rxcb == 0)
+ {
+ TFE_PROXY_STAT_INCREASE(STAT_STREAM_INTERCEPT, 1);
+ _stream->is_first_call_rxcb = 1;
+ tfe_set_intercept_metric(&_stream->head, 1, 0, 0, 0, 0);
+ }
+
/*
* Peer connection is terminated, drain all data.
* This connection will be destoryed in __event_cb
@@ -675,6 +694,7 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
TFE_PROXY_STAT_INCREASE(STAT_STEERING_CLIENT_TX_B, inbuff_len);
// TODO: Delete the following code when support calling the tfe-plugin
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_DOWN_BYTES, inbuff_len);
+ tfe_set_intercept_metric(&_stream->head, 0, 1, inbuff_len, 0, 0);
_stream->downstream_rx_offset += inbuff_len;
}
else
@@ -682,6 +702,7 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
TFE_PROXY_STAT_INCREASE(STAT_STEERING_SERVER_TX_B, inbuff_len);
// TODO: Delete the following code when support calling the tfe-plugin
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_UP_BYTES, inbuff_len);
+ tfe_set_intercept_metric(&_stream->head, 0, 0, 0, 1, inbuff_len);
_stream->upstream_rx_offset += inbuff_len;
}
@@ -707,6 +728,7 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
{
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INTERCEPT, 1);
_stream->is_first_call_rxcb = 1;
+ tfe_set_intercept_metric(&_stream->head, 1, 0, 0, 0, 0);
}
outbuf = bufferevent_get_output(peer_conn->bev);
@@ -794,11 +816,13 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
if (dir == CONN_DIR_DOWNSTREAM)
{
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_DOWN_BYTES, rx_offset_increase);
+ tfe_set_intercept_metric(&_stream->head, 0, 1, rx_offset_increase, 0, 0);
_stream->downstream_rx_offset += rx_offset_increase;
}
else
{
TFE_PROXY_STAT_INCREASE(STAT_STREAM_INCPT_UP_BYTES, rx_offset_increase);
+ tfe_set_intercept_metric(&_stream->head, 0, 0, 0, 1, rx_offset_increase);
_stream->upstream_rx_offset += rx_offset_increase;
}