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 William Coughlin
GraceDB Server
Commits
ec6294cd
Commit
ec6294cd
authored
11 years ago
by
Branson Stephens
Browse files
Options
Downloads
Patches
Plain Diff
Added remaining changes for performance logging system.
parent
8623161b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
gracedb/views.py
+75
-0
75 additions, 0 deletions
gracedb/views.py
settings/default.py
+50
-0
50 additions, 0 deletions
settings/default.py
templates/gracedb/histogram.html
+4
-0
4 additions, 0 deletions
templates/gracedb/histogram.html
urls.py
+1
-0
1 addition, 0 deletions
urls.py
with
130 additions
and
0 deletions
gracedb/views.py
+
75
−
0
View file @
ec6294cd
...
...
@@ -44,6 +44,7 @@ MAX_QUERY_RESULTS = 1000
GRACEDB_DATA_DIR
=
settings
.
GRACEDB_DATA_DIR
import
json
import
datetime
def
index
(
request
):
# assert request.user
...
...
@@ -1155,3 +1156,77 @@ def taglogentry(request, graceid, num, tagname):
msg
=
"
Successfully applied tag %s to log message %s.
"
%
(
tagname
,
num
)
return
HttpResponse
(
msg
,
content_type
=
"
text
"
)
# XXX added by Branson. Performance metrics.
def
performance
(
request
):
# First, try to find the relevant logfile from settings.
try
:
logfilepath
=
settings
.
LOGGING
[
'
handlers
'
][
'
performance_file
'
][
'
filename
'
]
logfile
=
open
(
logfilepath
,
"
r
"
)
except
:
return
HttpResponse
(
"
Failed to locate performance log file. Sorry
"
)
# Now parse the log file
dateformat
=
'
%Y-%m-%dT%H:%M:%S
'
# ISO format. I think.
# Lookback time is 3 days.
dt_now
=
datetime
.
datetime
.
now
()
dt_min
=
dt_now
+
datetime
.
timedelta
(
days
=-
3
)
creation_status_totals
=
{}
annotation_status_totals
=
{}
total_create_requests
=
0
total_annotate_requests
=
0
totals_by_status
=
{}
totals_by_method
=
{}
for
line
in
logfile
:
datestring
=
line
[
0
:
len
(
'
YYYY-MM-DDTHH:MM:SS
'
)]
# Check the date to see whether it's fresh enough
dt
=
datetime
.
datetime
.
strptime
(
datestring
,
dateformat
)
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
():
totals_by_method
[
method
]
=
1
totals_by_status
[
method
]
=
{
status
:
1
}
else
:
totals_by_method
[
method
]
+=
1
if
status
not
in
totals_by_status
[
method
].
keys
():
totals_by_status
[
method
][
status
]
=
1
else
:
totals_by_status
[
method
][
status
]
+=
1
# Calculate summary information:
summaries
=
{}
for
method
in
totals_by_method
.
keys
():
summaries
[
method
]
=
{
'
gt_500
'
:
0
,
'
btw_300_500
'
:
0
}
for
key
in
totals_by_status
[
method
].
keys
():
if
key
>=
500
:
summaries
[
method
][
'
gt_500
'
]
+=
totals_by_status
[
method
][
key
]
elif
key
>=
300
:
summaries
[
method
][
'
btw_300_500
'
]
+=
totals_by_status
[
method
][
key
]
# Normalize
if
totals_by_method
[
method
]
>
0
:
for
key
in
summaries
[
method
].
keys
():
summaries
[
method
][
key
]
=
float
(
summaries
[
method
][
key
])
/
totals_by_method
[
method
]
context
=
{
'
summaries
'
:
summaries
,
'
current_time
'
:
str
(
dt_now
),
'
totals_by_status
'
:
totals_by_status
,
'
totals_by_method
'
:
totals_by_method
,
}
return
render_to_response
(
'
gracedb/performance.html
'
,
context
,
context_instance
=
RequestContext
(
request
))
This diff is collapsed.
Click to expand it.
settings/default.py
+
50
−
0
View file @
ec6294cd
...
...
@@ -190,6 +190,7 @@ ADMIN_GROUP_HEADER = None
ADMIN_GROUP
=
None
MIDDLEWARE_CLASSES
=
[
'
middleware.performance.PerformanceMiddleware
'
,
'
middleware.accept.AcceptMiddleware
'
,
'
middleware.cli.CliExceptionMiddleware
'
,
'
django.middleware.common.CommonMiddleware
'
,
...
...
@@ -239,3 +240,52 @@ STATICFILES_FINDERS = (
)
STATICFILES_DIRS
=
()
# XXX The following Log settings are for a performance metric.
import
logging
LOG_ROOT
=
'
/home/branson/logs
'
LOG_FILE_SIZE
=
1024
*
1024
# 1 MB
LOG_FILE_BAK_CT
=
3
# Filter objects to separate out each level of alert.
class
infoOnlyFilter
(
logging
.
Filter
):
def
filter
(
self
,
record
):
if
record
.
levelname
==
'
INFO
'
:
return
1
return
0
LOGGING
=
{
'
version
'
:
1
,
'
disable_existing_loggers
'
:
True
,
'
formatters
'
:
{
'
simple
'
:
{
'
format
'
:
'
%(asctime)s: %(message)s
'
,
'
datefmt
'
:
'
%Y-%m-%dT%H:%M:%S
'
,
},
},
'
handlers
'
:
{
'
null
'
:
{
'
level
'
:
'
DEBUG
'
,
'
class
'
:
'
django.utils.log.NullHandler
'
,
},
'
performance_file
'
:
{
'
class
'
:
'
logging.handlers.RotatingFileHandler
'
,
'
formatter
'
:
'
simple
'
,
'
filename
'
:
'
%s/gracedb_performance.log
'
%
LOG_ROOT
,
'
maxBytes
'
:
LOG_FILE_SIZE
,
'
backupCount
'
:
LOG_FILE_BAK_CT
,
},
},
'
loggers
'
:
{
'
django
'
:
{
'
handlers
'
:
[
'
null
'
],
'
propagate
'
:
True
,
'
level
'
:
'
INFO
'
,
},
'
middleware
'
:
{
'
handlers
'
:
[
'
performance_file
'
],
'
propagate
'
:
True
,
'
level
'
:
'
INFO
'
,
},
},
}
This diff is collapsed.
Click to expand it.
templates/gracedb/histogram.html
+
4
−
0
View file @
ec6294cd
...
...
@@ -137,5 +137,9 @@ function toggle(id) {
No rate charts.
{% endif %}
</div>
<br/>
<br/>
<a
href=
"{% url performance %}"
><h3>
GraceDB 3-day performance summary
</h3></a>
{% endblock %}
This diff is collapsed.
Click to expand it.
urls.py
+
1
−
0
View file @
ec6294cd
...
...
@@ -29,6 +29,7 @@ urlpatterns = patterns('',
(
r
'
^feeds/(?P<url>.*)/$
'
,
EventFeed
()),
url
(
r
'
^feeds/$
'
,
feedview
,
name
=
"
feeds
"
),
url
(
r
'
^performance/$
'
,
'
gracedb.views.performance
'
,
name
=
"
performance
"
),
url
(
r
'
^reports/$
'
,
'
gracedb.reports.histo
'
,
name
=
"
reports
"
),
url
(
r
'
^reports/gstlalcbc_report/(?P<format>(json|flex))?$
'
,
'
gracedb.reports.gstlalcbc_report
'
,
name
=
"
gstlalcbc_report
"
),
(
r
'
^reports/(?P<path>.+)$
'
,
'
django.views.static.serve
'
,
...
...
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