Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mtproto_proxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mtproto_proxy
Commits
80e6b268
Unverified
Commit
80e6b268
authored
Jan 28, 2019
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more detailed traffic metrics (tx and rx, per-listener and per-dc)
parent
da597f0f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
10 deletions
+27
-10
mtp_down_conn.erl
src/mtp_down_conn.erl
+6
-3
mtp_handler.erl
src/mtp_handler.erl
+8
-4
mtp_metric.erl
src/mtp_metric.erl
+13
-3
No files found.
src/mtp_down_conn.erl
View file @
80e6b268
...
@@ -104,8 +104,8 @@ handle_cast(shutdown, State) ->
...
@@ -104,8 +104,8 @@ handle_cast(shutdown, State) ->
{
stop
,
shutdown
,
State
}.
{
stop
,
shutdown
,
State
}.
handle_info
({
tcp
,
Sock
,
Data
},
#state
{
sock
=
Sock
}
=
S
)
->
handle_info
({
tcp
,
Sock
,
Data
},
#state
{
sock
=
Sock
,
dc_id
=
DcId
}
=
S
)
->
mtp_metric
:
count_inc
([
?
APP
,
received
,
bytes
],
byte_size
(
Data
),
#
{
labels
=>
[
downstream
]}),
mtp_metric
:
count_inc
([
?
APP
,
received
,
downstream
,
bytes
],
byte_size
(
Data
),
#
{
labels
=>
[
DcId
]}),
mtp_metric
:
histogram_observe
([
?
APP
,
tracker_packet_size
,
bytes
],
byte_size
(
Data
),
#
{
labels
=>
[
downstream
]}),
mtp_metric
:
histogram_observe
([
?
APP
,
tracker_packet_size
,
bytes
],
byte_size
(
Data
),
#
{
labels
=>
[
downstream
]}),
{
ok
,
S1
}
=
handle_downstream_data
(
Data
,
S
),
{
ok
,
S1
}
=
handle_downstream_data
(
Data
,
S
),
activate_if_no_overflow
(
S1
),
activate_if_no_overflow
(
S1
),
...
@@ -239,7 +239,10 @@ down_send(Packet, #state{sock = Sock, codec = Codec, dc_id = DcId} = St) ->
...
@@ -239,7 +239,10 @@ down_send(Packet, #state{sock = Sock, codec = Codec, dc_id = DcId} = St) ->
mtp_metric
:
rt
(
mtp_metric
:
rt
(
[
?
APP
,
downstream_send_duration
,
seconds
],
[
?
APP
,
downstream_send_duration
,
seconds
],
fun
()
->
fun
()
->
ok
=
gen_tcp
:
send
(
Sock
,
Encoded
)
ok
=
gen_tcp
:
send
(
Sock
,
Encoded
),
mtp_metric
:
count_inc
(
[
?
APP
,
sent
,
downstream
,
bytes
],
iolist_size
(
Encoded
),
#
{
labels
=>
[
DcId
]})
end
,
#
{
labels
=>
[
DcId
]}),
end
,
#
{
labels
=>
[
DcId
]}),
{
ok
,
St
#state
{
codec
=
Codec1
}}.
{
ok
,
St
#state
{
codec
=
Codec1
}}.
...
...
src/mtp_handler.erl
View file @
80e6b268
...
@@ -137,11 +137,11 @@ handle_cast(Other, State) ->
...
@@ -137,11 +137,11 @@ handle_cast(Other, State) ->
lager
:
warning
(
"Unexpected msg
~p
"
,
[
Other
]),
lager
:
warning
(
"Unexpected msg
~p
"
,
[
Other
]),
{
noreply
,
State
}.
{
noreply
,
State
}.
handle_info
({
tcp
,
Sock
,
Data
},
#state
{
sock
=
Sock
,
handle_info
({
tcp
,
Sock
,
Data
},
#state
{
sock
=
Sock
,
transport
=
Transport
,
transport
=
Transport
}
=
S
)
->
listener
=
Listener
}
=
S
)
->
%% client -> proxy
%% client -> proxy
Size
=
byte_size
(
Data
),
Size
=
byte_size
(
Data
),
mtp_metric
:
count_inc
([
?
APP
,
received
,
bytes
],
Size
,
#
{
labels
=>
[
upstream
]}),
mtp_metric
:
count_inc
([
?
APP
,
received
,
upstream
,
bytes
],
Size
,
#
{
labels
=>
[
Listener
]}),
mtp_metric
:
histogram_observe
([
?
APP
,
tracker_packet_size
,
bytes
],
Size
,
#
{
labels
=>
[
upstream
]}),
mtp_metric
:
histogram_observe
([
?
APP
,
tracker_packet_size
,
bytes
],
Size
,
#
{
labels
=>
[
upstream
]}),
case
handle_upstream_data
(
Data
,
S
)
of
case
handle_upstream_data
(
Data
,
S
)
of
{
ok
,
S1
}
->
{
ok
,
S1
}
->
...
@@ -274,7 +274,11 @@ up_send(Packet, #state{stage = tunnel,
...
@@ -274,7 +274,11 @@ up_send(Packet, #state{stage = tunnel,
mtp_metric
:
rt
([
?
APP
,
upstream_send_duration
,
seconds
],
mtp_metric
:
rt
([
?
APP
,
upstream_send_duration
,
seconds
],
fun
()
->
fun
()
->
case
Transport
:
send
(
Sock
,
Encoded
)
of
case
Transport
:
send
(
Sock
,
Encoded
)
of
ok
->
ok
;
ok
->
mtp_metric
:
count_inc
(
[
?
APP
,
sent
,
upstream
,
bytes
],
iolist_size
(
Encoded
),
#
{
labels
=>
[
Listener
]}),
ok
;
{
error
,
Reason
}
->
{
error
,
Reason
}
->
is_atom
(
Reason
)
andalso
is_atom
(
Reason
)
andalso
mtp_metric
:
count_inc
(
mtp_metric
:
count_inc
(
...
...
src/mtp_metric.erl
View file @
80e6b268
...
@@ -115,9 +115,19 @@ active_metrics() ->
...
@@ -115,9 +115,19 @@ active_metrics() ->
"Upstream self-healthcheck triggered some action"
,
"Upstream self-healthcheck triggered some action"
,
#
{
labels
=>
[
action
]}},
#
{
labels
=>
[
action
]}},
{
count
,
[
?
APP
,
received
,
bytes
],
{
count
,
[
?
APP
,
received
,
downstream
,
bytes
],
"Bytes transmitted from upstream/downstream socket"
,
"Bytes transmitted from downstream socket"
,
#
{
labels
=>
[
direction
]}},
#
{
labels
=>
[
dc_id
]}},
{
count
,
[
?
APP
,
received
,
upstream
,
bytes
],
"Bytes transmitted from upstream socket"
,
#
{
labels
=>
[
listener
]}},
{
count
,
[
?
APP
,
sent
,
downstream
,
bytes
],
"Bytes sent to downstream socket"
,
#
{
labels
=>
[
dc_id
]}},
{
count
,
[
?
APP
,
sent
,
upstream
,
bytes
],
"Bytes sent to upstream socket"
,
#
{
labels
=>
[
listener
]}},
{
histogram
,
[
?
APP
,
tracker_packet_size
,
bytes
],
{
histogram
,
[
?
APP
,
tracker_packet_size
,
bytes
],
"Received packet size"
,
"Received packet size"
,
#
{
labels
=>
[
direction
],
#
{
labels
=>
[
direction
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment