Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
657e55ed
Commit
657e55ed
authored
Jul 17, 2017
by
astaxie
Committed by
GitHub
Jul 17, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2692 from jerson/master
added statusCode and pattern to FilterMonitorFunc
parents
621c2539
c903de41
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
admin.go
admin.go
+3
-3
router.go
router.go
+9
-1
No files found.
admin.go
View file @
657e55ed
...
...
@@ -37,7 +37,7 @@ var beeAdminApp *adminApp
// FilterMonitorFunc is default monitor filter when admin module is enable.
// if this func returns, admin module records qbs for this request by condition of this function logic.
// usage:
// func MyFilterMonitor(method, requestPath string, t time.Duration) bool {
// func MyFilterMonitor(method, requestPath string, t time.Duration
, pattern string, statusCode int
) bool {
// if method == "POST" {
// return false
// }
...
...
@@ -50,7 +50,7 @@ var beeAdminApp *adminApp
// return true
// }
// beego.FilterMonitorFunc = MyFilterMonitor.
var
FilterMonitorFunc
func
(
string
,
string
,
time
.
Duration
)
bool
var
FilterMonitorFunc
func
(
string
,
string
,
time
.
Duration
,
string
,
int
)
bool
func
init
()
{
beeAdminApp
=
&
adminApp
{
...
...
@@ -62,7 +62,7 @@ func init() {
beeAdminApp
.
Route
(
"/healthcheck"
,
healthcheck
)
beeAdminApp
.
Route
(
"/task"
,
taskStatus
)
beeAdminApp
.
Route
(
"/listconf"
,
listConf
)
FilterMonitorFunc
=
func
(
string
,
string
,
time
.
Duration
)
bool
{
return
true
}
FilterMonitorFunc
=
func
(
string
,
string
,
time
.
Duration
,
string
,
int
)
bool
{
return
true
}
}
// AdminIndex is the default http.Handler for admin module.
...
...
router.go
View file @
657e55ed
...
...
@@ -849,7 +849,15 @@ Admin:
//admin module record QPS
if
BConfig
.
Listen
.
EnableAdmin
{
timeDur
:=
time
.
Since
(
startTime
)
if
FilterMonitorFunc
(
r
.
Method
,
r
.
URL
.
Path
,
timeDur
)
{
pattern
:=
""
if
routerInfo
!=
nil
{
pattern
=
routerInfo
.
pattern
}
statusCode
:=
context
.
ResponseWriter
.
Status
if
statusCode
==
0
{
statusCode
=
200
}
if
FilterMonitorFunc
(
r
.
Method
,
r
.
URL
.
Path
,
timeDur
,
pattern
,
statusCode
)
{
if
runRouter
!=
nil
{
go
toolbox
.
StatisticsMap
.
AddStatistics
(
r
.
Method
,
r
.
URL
.
Path
,
runRouter
.
Name
(),
timeDur
)
}
else
{
...
...
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