summaryrefslogtreecommitdiff
path: root/platform/src/tcp_stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/src/tcp_stream.cpp')
-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;
}