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
6768b7ba
Unverified
Commit
6768b7ba
authored
May 26, 2019
by
Сергей Прохоров
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor mtp_metric optimizations
parent
e66778ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
+25
-7
mtp_metric.erl
src/mtp_metric.erl
+25
-7
No files found.
src/mtp_metric.erl
View file @
6768b7ba
...
@@ -45,11 +45,30 @@ rt(Name, Fun, Extra) ->
...
@@ -45,11 +45,30 @@ rt(Name, Fun, Extra) ->
notify
(
Type
,
Name
,
Value
,
Extra
)
->
notify
(
Type
,
Name
,
Value
,
Extra
)
->
case
application
:
get_env
(
?
APP
,
metric_backend
)
of
case
get_backend
()
of
{
ok
,
Mod
}
->
undefined
->
Mod
:
notify
(
Type
,
Name
,
Value
,
Extra
);
false
;
_
->
Mod
->
false
Mod
:
notify
(
Type
,
Name
,
Value
,
Extra
)
end
.
get_backend
()
->
%% Cache resutl of application:get_env in process dict because it's on the hot path
case
erlang
:
get
(
metric_backend
)
of
undefined
->
case
application
:
get_env
(
?
APP
,
metric_backend
)
of
{
ok
,
Mod
}
when
Mod
=/=
false
;
Mod
=/=
undefined
->
erlang
:
put
(
metric_backend
,
Mod
),
Mod
;
_
->
erlang
:
put
(
metric_backend
,
false
),
undefined
end
;
false
->
undefined
;
Mod
->
Mod
end
.
end
.
-
spec
passive_metrics
()
->
[{
metric_type
(),
metric_name
(),
metric_doc
(),
-
spec
passive_metrics
()
->
[{
metric_type
(),
metric_name
(),
metric_doc
(),
...
@@ -80,8 +99,7 @@ passive_metrics() ->
...
@@ -80,8 +99,7 @@ passive_metrics() ->
[{
gauge
,
[
?
APP
,
connections
,
count
],
[{
gauge
,
[
?
APP
,
connections
,
count
],
"Count of ranch connections"
,
"Count of ranch connections"
,
[{
#
{
listener
=>
H
},
proplists
:
get_value
(
all_connections
,
P
)}
[{
#
{
listener
=>
H
},
proplists
:
get_value
(
all_connections
,
P
)}
||
{
H
,
P
}
<-
ranch
:
info
(),
||
{
H
,
P
}
<-
mtproto_proxy_app
:
mtp_listeners
()]}]
].
proplists
:
get_value
(
protocol
,
P
)
==
mtp_handler
]}]
].
-
spec
active_metrics
()
->
[{
metric_type
(),
metric_name
(),
metric_doc
(),
Opts
}]
-
spec
active_metrics
()
->
[{
metric_type
(),
metric_name
(),
metric_doc
(),
Opts
}]
when
when
...
...
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