Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Coughlin
GraceDB Server
Commits
c20f601b
Commit
c20f601b
authored
7 years ago
by
Tanner Prestegard
Committed by
gracedb-dev1
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fixing performance logging
parent
6f5c4c0c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gracedb/view_logic.py
+10
-15
10 additions, 15 deletions
gracedb/view_logic.py
settings/default.py
+7
-4
7 additions, 4 deletions
settings/default.py
with
17 additions
and
19 deletions
gracedb/view_logic.py
+
10
−
15
View file @
c20f601b
...
@@ -34,6 +34,7 @@ from dateutil import parser
...
@@ -34,6 +34,7 @@ from dateutil import parser
from
django.utils
import
timezone
from
django.utils
import
timezone
import
logging
import
logging
import
pytz
import
pytz
import
re
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -327,9 +328,6 @@ def get_performance_info():
...
@@ -327,9 +328,6 @@ def get_performance_info():
logfilepath
=
settings
.
LOGGING
[
'
handlers
'
][
'
performance_file
'
][
'
filename
'
]
logfilepath
=
settings
.
LOGGING
[
'
handlers
'
][
'
performance_file
'
][
'
filename
'
]
logfile
=
open
(
logfilepath
,
"
r
"
)
logfile
=
open
(
logfilepath
,
"
r
"
)
# Now parse the log file
dateformat
=
'
%Y-%m-%dT%H:%M:%S
'
# ISO format. I think.
# Lookback time is 3 days. These are in UTC.
# Lookback time is 3 days. These are in UTC.
dt_now
=
timezone
.
now
()
dt_now
=
timezone
.
now
()
dt_min
=
dt_now
+
datetime
.
timedelta
(
days
=-
3
)
dt_min
=
dt_now
+
datetime
.
timedelta
(
days
=-
3
)
...
@@ -343,20 +341,17 @@ def get_performance_info():
...
@@ -343,20 +341,17 @@ def get_performance_info():
totals_by_method
=
{}
totals_by_method
=
{}
for
line
in
logfile
:
for
line
in
logfile
:
datestring
=
line
[
0
:
len
(
'
YYYY-MM-DDTHH:MM:SS
'
)]
try
:
match
=
re
.
search
(
r
'
^(.*) \| (\w+): (\d+): (\S+)$
'
,
line
)
datestring
,
method
,
status
,
username
=
match
.
groups
()
except
:
continue
# Check the date to see whether it's fresh enough
# Check the date to see whether it's fresh enough
dt
=
datetime
.
datetime
.
strptime
(
datestring
,
dateformat
)
dt
=
datetime
.
datetime
.
strptime
(
datestring
,
settings
.
LOG_DATEFMT
)
# Localize so we can compare with aware datetimes
# Localize so we can compare with aware datetimes
dt
=
SERVER_TZ
.
localize
(
dt
)
dt
=
SERVER_TZ
.
localize
(
dt
)
if
dt
>
dt_min
:
if
dt
>
dt_min
:
# Get rid of the datestring and the final colon.
line
=
line
[
len
(
datestring
)
+
1
:]
# Parse
method
,
status
,
username
=
line
.
split
(
'
:
'
)
method
=
method
.
strip
()
status
=
int
(
status
.
strip
())
username
=
username
.
strip
()
if
method
not
in
totals_by_method
.
keys
():
if
method
not
in
totals_by_method
.
keys
():
totals_by_method
[
method
]
=
1
totals_by_method
[
method
]
=
1
totals_by_status
[
method
]
=
{
status
:
1
}
totals_by_status
[
method
]
=
{
status
:
1
}
...
@@ -387,8 +382,8 @@ def get_performance_info():
...
@@ -387,8 +382,8 @@ def get_performance_info():
'
totals_by_status
'
:
totals_by_status
,
'
totals_by_status
'
:
totals_by_status
,
'
totals_by_method
'
:
totals_by_method
,
'
totals_by_method
'
:
totals_by_method
,
}
}
return
context
return
context
#
#
# A utility to be used with the gracedb.views.view to determine whether
# A utility to be used with the gracedb.views.view to determine whether
...
...
This diff is collapsed.
Click to expand it.
settings/default.py
+
7
−
4
View file @
c20f601b
...
@@ -378,6 +378,7 @@ LOG_FILE_SIZE = 1024*1024 # 1 MB
...
@@ -378,6 +378,7 @@ LOG_FILE_SIZE = 1024*1024 # 1 MB
LOG_FILE_BAK_CT
=
10
LOG_FILE_BAK_CT
=
10
LOG_FORMAT
=
'
extra_verbose
'
LOG_FORMAT
=
'
extra_verbose
'
LOG_LEVEL
=
'
DEBUG
'
LOG_LEVEL
=
'
DEBUG
'
LOG_DATEFMT
=
'
%Y-%m-%d %H:%M:%S
'
# Note that mode for log files is 'a' (append) by default
# Note that mode for log files is 'a' (append) by default
# The 'level' specifier on the handle is optional, and we
# The 'level' specifier on the handle is optional, and we
...
@@ -388,16 +389,16 @@ LOGGING = {
...
@@ -388,16 +389,16 @@ LOGGING = {
'
formatters
'
:
{
'
formatters
'
:
{
'
simple
'
:
{
'
simple
'
:
{
'
format
'
:
'
%(asctime)s | %(message)s
'
,
'
format
'
:
'
%(asctime)s | %(message)s
'
,
'
datefmt
'
:
'
%Y-%m-%d %H:%M:%S
'
,
'
datefmt
'
:
LOG_DATEFMT
,
},
},
'
verbose
'
:
{
'
verbose
'
:
{
'
format
'
:
'
%(asctime)s | %(name)s | %(message)s
'
,
'
format
'
:
'
%(asctime)s | %(name)s | %(message)s
'
,
'
datefmt
'
:
'
%Y-%m-%d %H:%M:%S
'
,
'
datefmt
'
:
LOG_DATEFMT
,
},
},
'
extra_verbose
'
:
{
'
extra_verbose
'
:
{
'
format
'
:
'
%(asctime)s.%(msecs)03d | %(name)s | %(levelname)s |
'
\
'
format
'
:
'
%(asctime)s.%(msecs)03d | %(name)s | %(levelname)s |
'
\
+
'
%(filename)s, line %(lineno)s | %(message)s
'
,
+
'
%(filename)s, line %(lineno)s | %(message)s
'
,
'
datefmt
'
:
'
%Y-%m-%d %H:%M:%S
'
,
'
datefmt
'
:
LOG_DATEFMT
,
}
}
},
},
'
handlers
'
:
{
'
handlers
'
:
{
...
@@ -422,7 +423,9 @@ LOGGING = {
...
@@ -422,7 +423,9 @@ LOGGING = {
'
level
'
:
'
ERROR
'
,
'
level
'
:
'
ERROR
'
,
},
},
'
performance_file
'
:
{
'
performance_file
'
:
{
'
class
'
:
'
logging.FileHandler
'
,
'
class
'
:
'
logging.handlers.ConcurrentRotatingFileHandler
'
,
'
maxBytes
'
:
1024
*
1024
,
'
backupCount
'
:
1
,
'
formatter
'
:
'
simple
'
,
'
formatter
'
:
'
simple
'
,
'
filename
'
:
'
%s/gracedb_performance.log
'
%
LOG_ROOT
,
'
filename
'
:
'
%s/gracedb_performance.log
'
%
LOG_ROOT
,
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment